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.
|
- import 'package:farm_tpf/data/repository/repository.dart';
- import 'package:rxdart/rxdart.dart';
-
- class GetHarvestBloc {
- final _repository = Repository();
- final _getHarvestFetcher = PublishSubject<dynamic>();
-
- Stream<dynamic> get actions => _getHarvestFetcher.stream;
-
- void getHarvests(
- Function(dynamic) onSuccess, Function(String) onError) async {
- try {
- _repository.getHarvests().then((value) {
- onSuccess(value);
- _getHarvestFetcher.sink.add(value);
- }).catchError((onError) {
- _getHarvestFetcher.addError(onError);
- onError(onError);
- });
- } catch (e) {
- _getHarvestFetcher.addError(e);
- onError(e);
- }
- }
-
- void dispose() async {
- await _getHarvestFetcher.drain();
- _getHarvestFetcher.close();
- }
- }
-
- final getHarvestBloc = GetHarvestBloc();
|