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

Add support for WeakRefs #3637

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Matchlighter
Copy link
Collaborator

Implement options for making computeds and reactions/autoruns garbage-collectable without manually disposing them.

I've had a couple apps that I've needed to use keepAlive computeds. I'm lazy and can't make promises that future me/future my app will dispose them properly. Now that JS supports WeakRefs, this is a less of a problem. The use case is pretty slim, mainly around computed(() => {}, { keepAlive: true }) stuff, but it can be used for autoruns too (though you'll need to keep a reference to the autorun in some other way less it fall out of scope and get garbage collected).

  • Added/updated unit tests
  • Updated /docs. For new functionality, at least API.md should be updated
  • Verified that there is no significant performance drop (yarn mobx test:performance)

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2023

🦋 Changeset detected

Latest commit: c20a32c

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

This PR includes changesets to release 1 package
Name Type
mobx Minor

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

@Matchlighter Matchlighter force-pushed the weakref branch 3 times, most recently from 1bf10cd to 59d94d4 Compare February 27, 2023 20:57
@rvion
Copy link

rvion commented Oct 8, 2024

nice, sounds handy !

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