Will multiple watchers on the same select & join set notify for every update to that table #3661
-
I don't know if that title makes any sense 😅 I'm listening to a table with multiple streams acting with different filters. Each have the same select table and joins, but each stream has different filters, aggregates etc. I want the results all to come in at the same time, but on this query the different streams have quite different response times which leads to a bit of lag between results, and unpleasant UX. I'm thinking of using RxDart's ZipStream function, which waits until the latest to emit before emitting all of them, but it requires that the streams all emit the same number of results, and I'm not sure if drift guarantees that? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Streams are indeed very hard to work with. Onto your issue, it sounds like you have multiple streams whose results you'd like to combine. However, you don't want to have the results of different queries in the same output. One way of solving this issue is to have a single watch query and have any other queries run on each event: Here is an example of a stream doing more work after each event"
The issue with the above approach is that the queries will run after one another, making them much slower. |
Beta Was this translation helpful? Give feedback.
-
If you know that you need to combine multiple results, another option may be to:
There's a similar issue about this here: #3338. This is something we could potentially improve with better APIs. |
Beta Was this translation helpful? Give feedback.
If you know that you need to combine multiple results, another option may be to:
tableUpdates
method to listen on changes on all source tables you're interested in.asyncMap
to, in response to receiving a table update, run all queries you're interested in to emit at once.There's a similar issue about this here: #3338. This is something we could potentially improve with better APIs.