I have setup a sqlite stream from Drift: Stream<List> into my @oberservable class. I can make it an OberserableStream, but I dont understand how to get the list from the stream.
My question is how can I get the list from the ObservableStream and make it an ObservableList or make it an ObeservableList directly from Stream?
Here’s what I got wrong so far. I have tried many permutations of this but IDE keeps telling me that its wrong type, wrong .map, wrong <whatever>
@observable
ObservableList<TodoDrift> streamTodos() {
ObservableStream<List<TodoDrift>> list = stObv.asObservable();
List<TodoDrift> prod = list.map(
(e) {
return e.done != true;
});
return prod.asObservable();
// return Future.wait(olStream);
}
Thank you!
FWIW. I also have a Future<List> from Drift and that works fine, I can get the list from there, so that works and I know the data is there.
2
Answers
based on @pskink question, Here is the working code.
State (mobx):
Display:
answering your original question: this is how you could do that:
BUT, this is really useless to do that since you already have
ObservableStream
which you can directly use insideObserver
widget: