diff --git a/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart b/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart index 67648935..d5514589 100644 --- a/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart +++ b/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart @@ -44,6 +44,19 @@ class AuthenticationRepositoryImpl }) : _authChangeListener = onAuthChange, _accountStreamTransformer = accountStreamTransformer { _formRepository = formRepository ?? FormRepositoryImpl(); + _accountStreamTransformer ??= (input) => input + .where((event) => event is! SignUpAuthChangeEvent) + .map>>((event) async { + if (listener == null) { + return Ok(AccountWrapperModel(event.account, null)); + } + // Handle sign in, sign out and refresh + final dataResult = await listener!.call(this, event); + return dataResult.map((data) { + authenticationCacheDataSource.storeData(data); + return AccountWrapperModel(event.account, data); + }); + }); if (formRepository != null) { return; } @@ -90,19 +103,6 @@ class AuthenticationRepositoryImpl name: AuthFormName.passwordResetForm, ), ); - _accountStreamTransformer ??= (input) => input - .where((event) => event is! SignUpAuthChangeEvent) - .map>>((event) async { - if (listener == null) { - return Ok(AccountWrapperModel(event.account, null)); - } - // Handle sign in, sign out and refresh - final dataResult = await listener!.call(this, event); - return dataResult.map((data) { - authenticationCacheDataSource.storeData(data); - return AccountWrapperModel(event.account, data); - }); - }); } final AuthenticationCacheDataSource authenticationCacheDataSource; final AuthenticationRemoteDataSource authenticationRemoteDataSource;