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 5904d2a4..134c1bf8 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
@@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+import 'dart:async';
+
+import 'package:rxdart/rxdart.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_authentication_bloc/src/core/constants/form_field.dart';
import 'package:wyatt_authentication_bloc/src/core/constants/form_name.dart';
@@ -43,6 +46,8 @@ class AuthenticationRepositoryImpl
final OnSignUpSuccess? _onSignUpSuccess;
final OnAuthChange? _onAccountChanges;
+ final StreamController>> _signUpStream =
+ StreamController();
bool _pause = false; // Semaphore
@@ -134,7 +139,11 @@ class AuthenticationRepositoryImpl
_formRepository.accessForm(AuthFormName.signUpForm).clone(),
);
await dataResult.foldAsync(
- _authenticationLocalDataSource.storeData,
+ (data) async {
+ await _authenticationLocalDataSource.storeData(data);
+ _signUpStream
+ .add(Future.value(Ok(AccountWrapperModel(account, data))));
+ },
(error) async => error,
);
}
@@ -205,16 +214,21 @@ class AuthenticationRepositoryImpl
);
@override
- Stream>> streamAccount() =>
- _authenticationRemoteDataSource.streamAccount().map((account) async {
- if (_onAccountChanges.isNotNull && !_pause) {
- final dataResult = await _onAccountChanges!.call(account);
- return dataResult.map((data) => AccountWrapperModel(account, data));
- }
- return Ok, AppException>(
- AccountWrapperModel(account, null),
- );
- });
+ Stream>> streamAccount() => MergeStream([
+ _signUpStream.stream.asBroadcastStream(),
+ _authenticationRemoteDataSource.streamAccount().map((account) async {
+ if (_onAccountChanges.isNotNull && !_pause) {
+ final dataResult = await _onAccountChanges!.call(account);
+ return dataResult.map((data) {
+ _authenticationLocalDataSource.storeData(data);
+ return AccountWrapperModel(account, data);
+ });
+ }
+ return Ok, AppException>(
+ AccountWrapperModel(account, null),
+ );
+ })
+ ]);
@override
FutureResult confirmPasswordReset({
diff --git a/packages/wyatt_authentication_bloc/pubspec.yaml b/packages/wyatt_authentication_bloc/pubspec.yaml
index fe566e4a..fc158118 100644
--- a/packages/wyatt_authentication_bloc/pubspec.yaml
+++ b/packages/wyatt_authentication_bloc/pubspec.yaml
@@ -21,6 +21,7 @@ dependencies:
flutter_facebook_auth: ^4.3.0
sign_in_with_apple: ^3.3.0
twitter_login: ^4.2.3
+ rxdart: ^0.27.7
wyatt_form_bloc:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/