(fix) #641 unsubscribe Not Triggered with syncObservable#642
Open
msantang78 wants to merge 2 commits intoLegendApp:mainfrom
Open
(fix) #641 unsubscribe Not Triggered with syncObservable#642msantang78 wants to merge 2 commits intoLegendApp:mainfrom
msantang78 wants to merge 2 commits intoLegendApp:mainfrom
Conversation
185da64 to
17192e1
Compare
17192e1 to
5f9fe4e
Compare
There was a problem hiding this comment.
Pull request overview
Fixes #641 by ensuring observables configured via syncObservable are recognized as “synced”, allowing listener-cleared propagation to trigger the underlying unsubscribe when the last observer is removed (including when only a nested property was observed).
Changes:
- Mark the target node as synced inside
syncObservableto enable correct cleanup/unsubscribe behavior. - Add
markNodeAsSyncedhelper inonChangeto centralize the synced-marking behavior. - Add a React test covering unmount → last observer removed → underlying unsubscribe called for
syncObservable.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/react.test.tsx |
Adds a regression test ensuring syncObservable subscriptions unsubscribe after unmount when observing a nested property. |
src/sync/syncObservable.ts |
Marks the node as synced at setup time so listener-cleared events propagate as expected. |
src/onChange.ts |
Introduces markNodeAsSynced and simplifies synced detection typing to support the new behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
7debbdd to
ff06987
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR solves #641
The synced observables created by
syncObservablewere not marked as synced, so the previous fix that I did for #621 was not working in this case.