.observe changes to a subtree of Doc

I might have missed it, but I haven’t found a means of subscribing to changes of a subtree of Doc. I can listen to any changes, using Doc.on('update', listener). But Doc.getMap('key').observe(listener) appears to only fire in response to direct updates on Map, and not to updates to descendants of Map, in the document tree.

Is this supported or encouraged by yjs?

Hi @ajhyndman,

update fires on document updates. observe fires on type changes. And observeDeep fires if the type or any of its children changes.

All types support observeDeep. It receives an array of update events that describes the changes on all its children. You can have a look at the type documentation in the Yjs Readme https://github.com/yjs/yjs

Ahh, I missed this method. Thank you!