Cancel effects when root store deallocates #3613
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.
We have wanted to do this for a long time, but our last attempt (#2643) needed to be reverted (#2648) because it meant that uncached stores (i.e. stores created using deprecated closure-based
scopes) would accidentally cancel their effects prematurely since those kinds of stores are created, destroyed and recreated often.However, in #2664 we separated the concept of the "root store" that powers a composition of features from a "child store" that can be derived and handed off to child features. The root store is what runs effects and holds onto cancellables, and now it is completely legitimate to tear down effects when the root store is deallocated.