How to create a watched query which depends on a streamed parameter? #2797
Replies: 1 comment 1 reply
-
I don't think this should be part of drift itself, but it sounds like you can build this by composing streams. The import 'package:rxdart/rxdart.dart';
Stream<Rows> myQuery(Stream<String> description) {
return description.switchMap((desc) => driftStreamWithParameter(desc));
} Of course, depending on the state management you're using to manage the description filter, other techniques also come to mind (e.g. if it's part of a state set with |
Beta Was this translation helpful? Give feedback.
-
I am directly populating a SliverList builder from a watched query in drift.
The query used to produce the Stream takes a filter argument (string), which is used to filter the results (i.e. on description).
I essentially want the stream to reevaluate not only when the underlying table changes (which happens today, thank you :)) - but also when any of my query arguments change.
If this were possible, it would greatly simplify the code in my widgets.
I am thinking, that the query needs to be able to accept a Stream instead of just a String expression... that would be awesome... am I barking up the wrong tree? Am I expecting too much from Drift?
I am really loving Drift, I'm so close to where I want to be (the data just streams through to the UI, user interactive filtering, pagination and all) - but I'm not sure I can make it over this last mile...
Beta Was this translation helpful? Give feedback.
All reactions