Implementation
TutorialEntryListBloc(
{this.filter,
this.paged,
this.orderBy,
this.descending,
this.detailed,
this.eliudQuery,
required TutorialEntryRepository tutorialEntryRepository,
this.tutorialEntryLimit = 5})
: _tutorialEntryRepository = tutorialEntryRepository,
super(TutorialEntryListLoading()) {
on<LoadTutorialEntryList>((event, emit) {
if ((detailed == null) || (!detailed!)) {
_mapLoadTutorialEntryListToState();
} else {
_mapLoadTutorialEntryListWithDetailsToState();
}
});
on<NewPage>((event, emit) {
pages = pages +
1; // it doesn't matter so much if we increase pages beyond the end
_mapLoadTutorialEntryListWithDetailsToState();
});
on<TutorialEntryChangeQuery>((event, emit) {
eliudQuery = event.newQuery;
if ((detailed == null) || (!detailed!)) {
_mapLoadTutorialEntryListToState();
} else {
_mapLoadTutorialEntryListWithDetailsToState();
}
});
on<AddTutorialEntryList>((event, emit) async {
await _mapAddTutorialEntryListToState(event);
});
on<UpdateTutorialEntryList>((event, emit) async {
await _mapUpdateTutorialEntryListToState(event);
});
on<DeleteTutorialEntryList>((event, emit) async {
await _mapDeleteTutorialEntryListToState(event);
});
on<TutorialEntryListUpdated>((event, emit) {
emit(_mapTutorialEntryListUpdatedToState(event));
});
}