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.

30 lines
852B

  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. print('get noti ok ${value.numberUnreadTotal}');
  12. onSuccess(value);
  13. _notiFetcher.sink.add(value);
  14. }).catchError((onError) {
  15. onError(onError);
  16. _notiFetcher.addError(onError);
  17. });
  18. }
  19. void dispose() async {
  20. await _notiFetcher.drain();
  21. _notiFetcher.close();
  22. }
  23. }
  24. final updateCountNotiBloc = UpdateCountNotiBloc();