ShopListBloc constructor
ShopListBloc({
- FilterShopModels? filter,
- bool? paged,
- String? orderBy,
- bool? descending,
- bool? detailed,
- EliudQuery? eliudQuery,
- required ShopRepository shopRepository,
- int shopLimit = 5,
Implementation
ShopListBloc(
{this.filter,
this.paged,
this.orderBy,
this.descending,
this.detailed,
this.eliudQuery,
required ShopRepository shopRepository,
this.shopLimit = 5})
: _shopRepository = shopRepository,
super(ShopListLoading()) {
on<LoadShopList>((event, emit) {
if ((detailed == null) || (!detailed!)) {
_mapLoadShopListToState();
} else {
_mapLoadShopListWithDetailsToState();
}
});
on<NewPage>((event, emit) {
pages = pages +
1; // it doesn't matter so much if we increase pages beyond the end
_mapLoadShopListWithDetailsToState();
});
on<ShopChangeQuery>((event, emit) {
eliudQuery = event.newQuery;
if ((detailed == null) || (!detailed!)) {
_mapLoadShopListToState();
} else {
_mapLoadShopListWithDetailsToState();
}
});
on<AddShopList>((event, emit) async {
await _mapAddShopListToState(event);
});
on<UpdateShopList>((event, emit) async {
await _mapUpdateShopListToState(event);
});
on<DeleteShopList>((event, emit) async {
await _mapDeleteShopListToState(event);
});
on<ShopListUpdated>((event, emit) {
emit(_mapShopListUpdatedToState(event));
});
}