Skip to content

How Streams provided by watch() are managed? #1024

Answered by simolus3
givip asked this question in Q&A
Discussion options

You must be logged in to vote

If I simply cancel subscription is it enough to right memory management?

Yes, moor will evict cached data shortly after the last listener detaches from a stream.

If I call watch multiple times is it returns the same stream or the new one?

If you call watch() while another listener is active, the stream will be re-used. You might get a different stream instance, but they will be powered by the same underlying StreamController. Further, moor will cache the latest value of a stream so that the query won't be run if it's not necessary.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by givip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants