mobx icon indicating copy to clipboard operation
mobx copied to clipboard

Add support for WeakRefs

Open Matchlighter opened this issue 2 years ago • 2 comments

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

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

Matchlighter avatar Feb 24 '23 22:02 Matchlighter

🦋 Changeset detected

Latest commit: c20a32c73f5487fa53c3070cee16a8936781e78a

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

changeset-bot[bot] avatar Feb 24 '23 22:02 changeset-bot[bot]