call observers in parent nodes
This commit is contained in:
parent
022ce6da03
commit
b92785f495
@ -49,3 +49,11 @@
|
|||||||
(s:observe [:foo] #(set win true))
|
(s:observe [:foo] #(set win true))
|
||||||
(s:update [:foo :bar] 42)
|
(s:update [:foo :bar] 42)
|
||||||
(expect (and win)))
|
(expect (and win)))
|
||||||
|
|
||||||
|
(let [s (observable.new {:foo {:bar {:baz 43}}})]
|
||||||
|
(var win 0)
|
||||||
|
;; observers on ancestor trees are called after child trees
|
||||||
|
(s:observe [:foo] #(set win (/ win 2)))
|
||||||
|
(s:observe [:foo :bar] #(set win 4))
|
||||||
|
(s:update [:foo :bar :baz] 42)
|
||||||
|
(expect (= win 2)))
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
(fn update [data self path value]
|
(fn update [data self path value]
|
||||||
(let [[first & rest] path]
|
(let [[first & rest] path]
|
||||||
(if (next rest)
|
(if (next rest)
|
||||||
|
(do
|
||||||
(update (. data first) self rest value)
|
(update (. data first) self rest value)
|
||||||
|
(if data._subscribers
|
||||||
|
(each [_ f (pairs data._subscribers)] (f))))
|
||||||
(do
|
(do
|
||||||
(if data._subscribers
|
(if data._subscribers
|
||||||
(each [_ f (pairs data._subscribers)] (f)))
|
(each [_ f (pairs data._subscribers)] (f)))
|
||||||
|
Loading…
Reference in New Issue
Block a user