Skip to content

(fix) #641 unsubscribe Not Triggered with syncObservable#642

Open
msantang78 wants to merge 2 commits intoLegendApp:mainfrom
msantang78:fix/unsubscribe-syncObservable-641
Open

(fix) #641 unsubscribe Not Triggered with syncObservable#642
msantang78 wants to merge 2 commits intoLegendApp:mainfrom
msantang78:fix/unsubscribe-syncObservable-641

Conversation

@msantang78
Copy link
Contributor

This PR solves #641

The synced observables created by syncObservable were not marked as synced, so the previous fix that I did for #621 was not working in this case.

@msantang78 msantang78 force-pushed the fix/unsubscribe-syncObservable-641 branch 2 times, most recently from 185da64 to 17192e1 Compare March 2, 2026 21:51
@msantang78 msantang78 force-pushed the fix/unsubscribe-syncObservable-641 branch from 17192e1 to 5f9fe4e Compare March 2, 2026 21:54
@DorianMazur DorianMazur requested a review from Copilot March 9, 2026 15:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 syncObservable to enable correct cleanup/unsubscribe behavior.
  • Add markNodeAsSynced helper in onChange to 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.

@msantang78 msantang78 force-pushed the fix/unsubscribe-syncObservable-641 branch from 7debbdd to ff06987 Compare March 9, 2026 16:38
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