getFilteredStream method
Implementation
Stream<CRUDEvent<TDao, TPrimaryKey>> getFilteredStream(Filter filter) =>
_streamController.stream
.asyncMap((event) async {
if (event is CreateEvent<TDao, TPrimaryKey>) {
if (await matchesFilter(event.item, filter)) {
return event;
} else {
return null;
}
} else if (event is UpdateEvent<TDao, TPrimaryKey>) {
if (await matchesFilter(event.item, filter)) {
return event;
} else {
return null;
}
} else {
return event;
}
})
.where((event) => event != null)
.cast<CRUDEvent<TDao, TPrimaryKey>>();