Make it easier to write lazy streams #10494
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR incorporates stream-list.
This commit manages a lifecycle for streams. If a stream has no
subscribers, it is considered "inactive". When a stream gets
subscribers, it becomes "active".
A stream can register dependencies on other streams regardless of
whether the stream itself is active. When the stream becomes active, the
dependency will activate its subscriptions. When the stream becomes
inactive, the dependency will deactivate its subscriptions.
When a stream is destroyed, it automatically deactivates the
subscriptions of all dependencies.
This commit also add a new "revalidate" hook for streams, which gets
invoked when the
valueFn
is called, and right before a stream becomesactive. This hook can be used to tear down any state on the old value of
a dependent stream. For example, the
KeyStream
uses this hook to teardown observers when the backing object for the stream has changed.