Yomguithereal / baobab

JavaScript & TypeScript persistent and optionally immutable data tree with cursors.
MIT License
3.15k stars 117 forks source link

Monkeys do not trigger parent updates when they update #437

Open dumconstantin opened 8 years ago

dumconstantin commented 8 years ago

When a monkey is updated it does not dispatch an update event to its parent:

let tree = new Baobab({
  a: {
    b: 10,
    c: monkey(['foo'], x => x)
 },
 foo: 20
})
tree.select('a').on('update', () => console.log('updated a'))
tree.select('a', 'c').on('update', () => console.log('updated monkey'))

tree.select('foo').set(123); 
// updated monkey
// BUT does not trigger "update a" on the parent

// on the other hand
tree.select('a', 'b').set(123);
// updated a

Is there a possibility to make a monkey trigger a parent update?

(I'm using 2.3.0)