Skip to content

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

@changeset-bot
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

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
7 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.

3 participants