Skip to content

Conversation

@mbrandonw
Copy link
Member

@mbrandonw mbrandonw commented Feb 27, 2025

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.

@mbrandonw
Copy link
Member Author

This PR may fix #2508

@stephencelis stephencelis merged commit 001d0e9 into main Feb 27, 2025
15 checks passed
@stephencelis stephencelis deleted the root-store-deinit branch February 27, 2025 22:18
@dk-jlew
Copy link

dk-jlew commented Mar 10, 2025

Fantastic, thank you!

@dk-jlew
Copy link

dk-jlew commented Mar 11, 2025

Can you tell me if this also fixes the situation where multiple stores of the same type, operating in disconnected contexts, will interfere with each others' effects? For instance, I have:
StoreA (root) -> StoreB (child)
...and separately (not connected by a common root) the same thing again:
StoreA (root) -> StoreB (child)

Formerly, if one instance StoreB was to be destroyed, it would potentially kill the effects of the unrelated StoreB instance, due to shared storage and identical KeyPaths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants