Closed Paul-Martin closed 9 years ago
Hi Paul,
Yes that is the current behavior: each path from a computed is treated as a separate path, and the deep linking concept applies separately to each path. So a.b.c().x.y.z()
will listen to change of c()
or z()
, and a^b.c().x.y^z()
will listen to changes of a
, b
, c()
, y
or z()
, but not x
.
So currently {^{for a().b()}}
is valid, and it is not necessary to write {^{for a()^b()}}
.
That said, let me mull over the design a bit - it is true that it is a bit unintuitive. I'll come back to this issue, once I have drilled into it a bit further...
As always, thanks Boris! I suspected that was the case, but I couldn't find it in the documentation.
On Oct 21, 2014, at 2:59 PM, Boris Moore notifications@github.com wrote:
Hi Paul,
Yes that is the current behavior: each path from a computed is treated as a separate path, and the deep linking concept applies separately to each path. So a.b.c().x.y.z() will listen to change of c() or z(), and a^b.c().x.y^z() will listen to changes of a, b, c(), y or z(), but not x.
So currently {^{for a().b()}} is valid, and it is not necessary to write {^{for a()^b()}}.
That said, let me mull over the design a bit - it is true that it is a bit unintuitive. I'll come back to this issue, once I have drilled into it a bit further...
— Reply to this email directly or view it on GitHub.
With update 61 this is now supported.
Depth of binding of paths is now controlled by the '^' character, whether or not the path includes computed values.
For example: "a.b().c"
will do leaf binding only, so will 'observe' (listen to) changes in c
, but NOT changes in b()
. (This is breaking, since previously this path DID observe b()
...)
To observe both c
and b()
, use the path: "a.b()^c"
To observe ALL changes in the path - a
, b()
and c()
, use: "a^b().c"
Hello Boris,
I noticed that it appears that paths made of computed observables are always deep linked. This may be intentional behavior, since each part of the path is computed, perhaps they must always be reevaluated. Could you clarify whether that is intended behavior. Here is a jsfiddle which shows two identical for loops.
http://jsfiddle.net/8sgnfbL9/
The first is using static objects with the path 'a.b'.
In this example, updating 'a' observably does not cause the for loop to be reevaluated.
The second is using computed observables with the path 'a().b()'.
In this example, updating 'a' observably DOES cause the for loop to be reevaluated. Is this intended behavior, or should this example only update if the path is 'a()^b()'?