Fakultas Ilmu Komputer UI

Commit 41ca4e37 authored by Dzaky Noor Hasyim's avatar Dzaky Noor Hasyim
Browse files

[GREEN] Adding kegiatan_terdekat_bloc

parent a75d4be5
import 'dart:async';
import 'package:bisaGo/network/data/network_model.dart';
import 'package:bisaGo/repository/kegiatan_terdekat_repository.dart';
import 'package:get_it/get_it.dart';
import 'package:rxdart/rxdart.dart';
class KegiatanTerdekatBloc {
KegiatanTerdekatRepository _kegiatanTerdekatRepository;
StreamController _kegiatanTerdekatController;
StreamSink<NetworkModel> get kegiatanTerdekatSink =>
_kegiatanTerdekatController.sink;
Stream<NetworkModel> get kegiatanTerdekatStream =>
_kegiatanTerdekatController.stream;
KegiatanTerdekatBloc() {
_kegiatanTerdekatController = BehaviorSubject<NetworkModel>();
_kegiatanTerdekatRepository = GetIt.instance.get<BaseKegiatanTerdekatRepository>();
fetchKegiatanTerdekat();
}
Future<void> fetchKegiatanTerdekat() async {
kegiatanTerdekatSink.add(NetworkModel.loading('Loading Kegiatan'));
try {
final kegiatanTerdekatResponse =
await _kegiatanTerdekatRepository.fetchKegiatanTerdekatResponse();
kegiatanTerdekatSink.add(NetworkModel.completed(kegiatanTerdekatResponse));
} catch (e) {
kegiatanTerdekatSink.add(NetworkModel.error(e.toString()));
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment