Open basicdays opened 7 years ago
I'll try to check that soon but yes, having monkeys in an array is probably a bad idea performance-wise.
Just started poking around in the source about it and found this in baobab.js line 166:
/**
* Internal method used to refresh the tree's monkey register on every
* update.
* Note 1) For the time being, placing monkeys beneath array nodes is not
* allowed for performance reasons.
*
* @param {mixed} node - The starting node.
* @param {array} path - The starting node's path.
* @param {string} operation - The operation that lead to a refreshment.
* @return {Baobab} - The tree instance for chaining purposes.
*/
_refreshMonkeys(node, path, operation) {
If you'd like, I just forked the repo. I could just add a notice in the readme that monkeys that are on a path with an array are not supported at this time for a PR. Wouldn't mind getting a bit more involved in this project. :)
I recall writing something about this in the README concerning monkeys and arrays but I guess I forgot. My bad. Don't hesitate to open a PR :).
Hey all,
Just ran into this bug. If I create a monkey that contains an array within its own path on the tree, it doesn't seem to be able to act as a getter. I'm currently on version 2.4.1. Here's some code to reproduce.
And its output:
Will probably rearchitect how I'm approaching the problem to work around this as I don't know the performance impact anyways.