fix: correct inner effect cleanup order - #62
Open
YuanchengLi-Kevin wants to merge 1 commit into
Open
Conversation
Owner
|
My only concern is that I intended for Charm to use first-in-first-out effect cleanup order since that seems more intuitive, and reversing this order might be a breaking change. I want to take a closer look at this when I'm able to and maybe propose changes to match reactivity's FIFO effect cleanup. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses issue #60 with owner's suggested fix.
TLDR: Clean up child effects and effect scopes before their parent reruns, and dispose dependencies in LIFO order.
New
unlinkChildEffects(sub): a helper function from the owner'sreactivityproject (https://github.com/littensy/reactivity/blob/main/src/init.luau#L343)disposeAllDepsInReverse(sub): unlinks all dependencies in LIFO order (translated from this alien-signal commit (stackblitz/alien-signals@713a1c6)HAS_CHILD: a flag that marks whether a node's dependencies includes at least one child effect or effect scope (alien-signals translation)Updated
run(): checkHAS_CHILDand unlink child effects before parent rerunstopEffect(): integratedisposeAllDepsInReverse()unwatched(): integratedisposeAllDepsInReverse()effect(): setHAS_CHILDflageffectScope(): setHAS_CHILDflagTests
effect.testtranslated from alien-signals (Passed)effectScope.testtranslated from alien-signals (Passed)