Closed Bnaya closed 3 years ago
Latest commit: 7c7a58b44205f6b6ae9e9e8a08b80efacad91084
The changes in this PR will be included in the next version bump.
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
@littledan - I don't know if this is interesting to you but I remember talking about use cases and behaviours for FinalizationRegistry some time ago (in the Node collab summit). This is a pretty solid one where React no longer guarantees it will call cleanup functions, MobX needs to run cleanup sometime in the future after the state/object is no longer retained and MobX will use a FinalizationRegistry to accomplish this.
I would be curious about whether or not you think this is a good idea (it's not like we have a choice anyway 😅 🤷♂️ )
@littledan - I don't know if this is interesting to you but I remember talking about use cases and behaviours for FinalizationRegistry some time ago (in the Node collab summit). This is a pretty solid one where React no longer guarantees it will call cleanup functions, MobX needs to run cleanup sometime in the future after the state/object is no longer retained and MobX will use a FinalizationRegistry to accomplish this.
I would be curious about whether or not you think this is a good idea (it's not like we have a choice anyway 😅 🤷♂️ )
Worth nothing that, this comes to replace heuristic, setTimeout based user-land garbage collector. If the component wasn't committed after XXX time, we will dispose the reaction.
Didn't review the tests, but the logic itself looks solid to me! Awesome approach :)
I will address the comments & do more browsers testing tomorrow, Hopefully also merge it
background: https://github.com/mobxjs/mobx/discussions/2562
On this PR we introduce additional mechanism to dispose reactions from uncommitted components
The new mechanism will kick-in when platforms supports finalization registry
High-level changes:
reactionCleanupTracking
now expose slightly different api that is covering both mechanisms, souseObserver
is agnostic to the actual implTest changes: The tests now must run using node 14 +
--expose-gc
We test both impls with single jest runCode change checklist
README
if applicable