import 'package:farm_tpf/custom_model/NotificationObjectDTO.dart'; import 'package:farm_tpf/data/repository/repository.dart'; import 'package:rxdart/rxdart.dart'; class UpdateCountNotiBloc { final _repository = Repository(); final _notiFetcher = PublishSubject(); Stream get actions => _notiFetcher.stream; void getNotifications(Function(NotificationObjectDTO) onSuccess, Function(String) onError) async { _repository.getNotifications().then((value) { print('get noti ok ${value.numberUnreadTotal}'); onSuccess(value); _notiFetcher.sink.add(value); }).catchError((onError) { onError(onError); _notiFetcher.addError(onError); }); } void dispose() async { await _notiFetcher.drain(); _notiFetcher.close(); } } final updateCountNotiBloc = UpdateCountNotiBloc();