Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve derived ownership model #13623

Merged
merged 3 commits into from
Oct 16, 2024
Merged

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Oct 16, 2024

#13563 introduced owned deriveds, but it turns out that eagerly attaching each derived to its parent effect upon creation wasn't ideal. Instead, we can lazily do it upon encountering a read on a derived in a context where there is no active reaction. I can't believe I didn't think of this sooner!

Before:
Screenshot 2024-10-16 at 12 17 46

After:
Screenshot 2024-10-16 at 12 18 12

Copy link

changeset-bot bot commented Oct 16, 2024

🦋 Changeset detected

Latest commit: 1ad80f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -488,7 +488,7 @@ describe('signals', () => {
assert.equal(a?.deps?.length, 1);
assert.equal(s?.reactions?.length, 1);
destroy();
assert.equal(a?.deps, null);
assert.equal(a?.deps?.length, 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The derived still gets GC'd so this check isn't all that important. I think it's best to remove this line.

@trueadm trueadm merged commit 6a38bbe into main Oct 16, 2024
9 checks passed
@trueadm trueadm deleted the improve-derived-ownerhsip branch October 16, 2024 11:30
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.

2 participants