You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use xstream streams as a store in a React project and I'm quite happy with it. The only issue I have is with MemoryStreams not working as I would expect with regards to caching.
I'm not sure if this is a bug or per design.
When I subscribe to a memory stream as the first subscriber (for the first time) the chain of computation starts and I eventually get a value, that the stream will cache for all the subsequent subscribers.
Now, when all the subscribers unsubscribe, the stream knows the latest computed value.
But when I subscribe again to it, it will start the chain of computation again, even though it already has the value for me.
Is this expected behaviour?
I see in the code that in MemoryStream#_stopNow method you explicitly tell the stream that the value is stale via _has flag:
Now, when all the subscribers unsubscribe, the stream knows the latest computed value.
I believe it is expected. After there no subscriptions anymore a stream actually completes (and "forgets" everything, actually it dies). If you subscribe again it will resurrect, but will not give you the latest value from its past life.
I'm trying to use xstream streams as a store in a React project and I'm quite happy with it. The only issue I have is with MemoryStreams not working as I would expect with regards to caching.
I'm not sure if this is a bug or per design.
When I subscribe to a memory stream as the first subscriber (for the first time) the chain of computation starts and I eventually get a value, that the stream will cache for all the subsequent subscribers.
Now, when all the subscribers unsubscribe, the stream knows the latest computed value.
But when I subscribe again to it, it will start the chain of computation again, even though it already has the value for me.
Is this expected behaviour?
I see in the code that in
MemoryStream#_stopNow
method you explicitly tell the stream that the value is stale via_has
flag:xstream/src/index.ts
Line 2010 in 61f364a
Could anyone explain the rationale behind it please?
EDIT: Here is a demo of the problem: https://glitch.com/edit/#!/polar-cry
The text was updated successfully, but these errors were encountered: