RoomListBloc constructor
RoomListBloc({
- FilterRoomModels? filter,
- bool? paged,
- String? orderBy,
- bool? descending,
- bool? detailed,
- EliudQuery? eliudQuery,
- required RoomRepository roomRepository,
- int roomLimit = 5,
Implementation
RoomListBloc(
{this.filter,
this.paged,
this.orderBy,
this.descending,
this.detailed,
this.eliudQuery,
required RoomRepository roomRepository,
this.roomLimit = 5})
: _roomRepository = roomRepository,
super(RoomListLoading()) {
on<LoadRoomList>((event, emit) {
if ((detailed == null) || (!detailed!)) {
_mapLoadRoomListToState();
} else {
_mapLoadRoomListWithDetailsToState();
}
});
on<NewPage>((event, emit) {
pages = pages +
1; // it doesn't matter so much if we increase pages beyond the end
_mapLoadRoomListWithDetailsToState();
});
on<RoomChangeQuery>((event, emit) {
eliudQuery = event.newQuery;
if ((detailed == null) || (!detailed!)) {
_mapLoadRoomListToState();
} else {
_mapLoadRoomListWithDetailsToState();
}
});
on<AddRoomList>((event, emit) async {
await _mapAddRoomListToState(event);
});
on<UpdateRoomList>((event, emit) async {
await _mapUpdateRoomListToState(event);
});
on<DeleteRoomList>((event, emit) async {
await _mapDeleteRoomListToState(event);
});
on<RoomListUpdated>((event, emit) {
emit(_mapRoomListUpdatedToState(event));
});
}