Implementation
SectionListBloc(
{this.filter,
this.paged,
this.orderBy,
this.descending,
this.detailed,
this.eliudQuery,
required SectionRepository sectionRepository,
this.sectionLimit = 5})
: _sectionRepository = sectionRepository,
super(SectionListLoading()) {
on<LoadSectionList>((event, emit) {
if ((detailed == null) || (!detailed!)) {
_mapLoadSectionListToState();
} else {
_mapLoadSectionListWithDetailsToState();
}
});
on<NewPage>((event, emit) {
pages = pages +
1; // it doesn't matter so much if we increase pages beyond the end
_mapLoadSectionListWithDetailsToState();
});
on<SectionChangeQuery>((event, emit) {
eliudQuery = event.newQuery;
if ((detailed == null) || (!detailed!)) {
_mapLoadSectionListToState();
} else {
_mapLoadSectionListWithDetailsToState();
}
});
on<AddSectionList>((event, emit) async {
await _mapAddSectionListToState(event);
});
on<UpdateSectionList>((event, emit) async {
await _mapUpdateSectionListToState(event);
});
on<DeleteSectionList>((event, emit) async {
await _mapDeleteSectionListToState(event);
});
on<SectionListUpdated>((event, emit) {
emit(_mapSectionListUpdatedToState(event));
});
}