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.

29 lines
797B

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