Can changes propagate through mixed nested types?

Hello,

I have a nested tree structure like:

let array = Y.Array<SomeObject>

interface SomeObject = {
  SomeField: string
  SomeMap: Y.Map<Foo>
}

I put an array.ObserveDeep on array but changes in SomeMap don’t seem to propagate upwards to the top level array. Is this behaviour intentional? Do Y objects have to be direct descendents of one another in order to propagate changes?

If it’s not possible to ObserveDeep nested mixed objects, would it be more idiomatic to do just make SomeField part of SomeMap like:

  Y.Array<Y.Map<Foo | string>>

Thanks!

Hi @elimist3,

do you basically set array.insert(0, [{ someField: 'string', someMap: new Y.Map() }])? That doesn’t work because you can either set JSON as a value OR a Yjs type. It is imperformant for Yjs to iterate through all JSON structures, which is why you should structure your application state differently.

The second approach should work :wink:

1 Like

Yes that’s exactly what I did. That makes sense that Yjs shouldn’t have to iterate through all JSON structures for performance reasons, thanks for your explanation and help.

BTW, Yjs is awesome - I believe CRDTs have a bright future!

Sure, np! Thanks :slight_smile: