You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
725B

  1. import 'package:farm_tpf/data/repository/user_repository.dart';
  2. import 'package:rxdart/rxdart.dart';
  3. class GetAccountBloc {
  4. final _repository = UserRepository();
  5. final _getAccountFetcher = PublishSubject<dynamic>();
  6. Stream<dynamic> get actions => _getAccountFetcher.stream;
  7. void getAccount(Function(dynamic) onSuccess, Function(String) onError) async {
  8. _repository.getUser().then((value) {
  9. onSuccess(value);
  10. _getAccountFetcher.sink.add(value);
  11. }).catchError((onError) {
  12. onError(onError);
  13. _getAccountFetcher.addError(onError);
  14. });
  15. }
  16. void dispose() async {
  17. await _getAccountFetcher.drain();
  18. _getAccountFetcher.close();
  19. }
  20. }
  21. final getAccountBloc = GetAccountBloc();