The documentation says that in a Model.observeObject, If the observed object is an Array, the change encodes only one type of mutation: splice.
Now my question is, if I have a tree (an array of arrays), and I have a observeObject on that Array, I will get notifications for the elements of the 1st level (correct me if I am wrong). So does it mean that I would have to add observers over the elements of 2nd level when I get the notifications of the 1st level (means, I get that A,B,C elements were added on the 1st level, then I add observers for its children)?
Assuming that the previous problem is "solved" (we get notification from all kind of mutations), if we have a tree that we
want to show as a DOM <ul>-<li> elements (flatten tree), in the next case:
Original tree:
A
A11
A12
A13
B
B21
B22
mutated the tree:
A
A11
C
C11
A12
B21
A13
B
B21
The mutation can be described as:
1 Level 1 splice 1 0 [ C, [C11] ]
2 Level 2 (A.children) splice 1 2
3 Level 2 (C.children) splice 1, 0 [result of prev splice]
4 Level 2 (B.children) splice 1, 1
5 Level 2 (C.children) splice 2, 0 [result of prev splice]
My questions are:
1. In which order I will get the notifications (notice the problem of swapping the splice sequence)?
2. How can I keep track of which element I need to move/insert in the DOM list?
3. Would it be possible to map that tree to another DOM "tree" (<ol> ...<li> <ul>...</ul> </li>) and still keep track on how to map all the changes?
Thanks in advance,
David