Yomguithereal / baobab

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

Fix #448 - monkeys don't emit update events #500

Closed roark closed 6 years ago

roark commented 6 years ago

... I separated out the hashPath function into the helpers.js file so it could be also used in monkey.js.

I then went ahead and manually updated the tree._affectedPathsIndex from within monkey.js... This aspect feels hacky as I'm directly updating the private variable of the baobab tree... That said, I did see several other instances updated tree._data and didn't want to take to many liberties restructuring.

Possibly a tree.addAffectedPath() method could be created to abstract away any access to private vars.

So this pull request does work as is, but could possibly be improved upon. Let me know what it needs to be pulled.

Thanks for the great library!

Yomguithereal commented 6 years ago

Hello @roark. This feels hacky indeed but seems to be a good fix for the time being. Let me merge and release asap.