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

Deep Observe #47

Merged
merged 3 commits into from
May 6, 2022
Merged

Deep Observe #47

merged 3 commits into from
May 6, 2022

Conversation

Waidhoferj
Copy link
Collaborator

@Waidhoferj Waidhoferj commented Apr 28, 2022

Fixes #43
Added deep observe option to all YTypes

Example

# will observe mutations directly on the `YArray` (old api)
sub = y_array.observe(fn)

# will recursively observe events inside the `YArray`
sub = y_array.observe(fn, deep=True)

Updates

  • Added documentation and test cases.
  • Implemented deep observe for YText, YMap, YArray, YXmlElement, and YXmlText.
  • Fixed issue where deep observers will not unsubscribe.
  • Tested YText deep observe with embedded objects (requires Added rich text formatting #21)

@Waidhoferj Waidhoferj added the enhancement New feature or request label Apr 28, 2022
@Waidhoferj Waidhoferj self-assigned this Apr 28, 2022
@Horusiath
Copy link

I'm not sure if using deep=True argument is desirable, as observe and observe_deep put different type signatures for subscriber callbacks in Yrs. observe uses a specific event per Y type. observe_deep is more generic and it's subscriber takes a list of events "bubbling up" from children Y types instead.

@Waidhoferj
Copy link
Collaborator Author

Additions

  • New trait DefaultPyErr to create centralized default error messages for custom Ypy exceptions
  • SubscriptionIds now obscure their contents in two classes: DeepSubscription and ShallowSubscription
  • unobserve now handles both deep and shallow subscriptions
  • Integrated rich text for YText

@Waidhoferj Waidhoferj marked this pull request as ready for review May 6, 2022 15:48
@Waidhoferj Waidhoferj merged commit b834098 into main May 6, 2022
@Waidhoferj Waidhoferj deleted the deep-observe branch May 6, 2022 15:48
@davidbrochart davidbrochart mentioned this pull request May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Observe is not recursive?
3 participants