I have a BLoC that consumes a raw input Stream
(that yields a list of JSON objects) and transforms it to usable objects using a StreamTransformer
.
Your assumption is correct. You need to create a third steam that takes both your JSON and Filter streams and combine both into a custom result.
This is usually done with a Stream transformer. Using myStream.transform
method. But this is kinda complicated.
To make things far easier, there's a package called rxdart which basically subclass Stream
and adds a few common transformers.
Using rxdart, you could create this third stream by using combineLatest
operator
Observable<List<String>> list;
Observable<String> filter;
final output = Observable.combineLatest2(filter, list, (String filter, List<String> list) {
return list.where((str) => str.startsWith(filter));
});
More informations on reactivex operators here