allow multiple subscribers on same node
This commit is contained in:
parent
117cb8be47
commit
3d64e42142
@ -57,3 +57,11 @@
|
||||
(s:observe [:foo :bar] #(set win 4))
|
||||
(s:update [:foo :bar :baz] 42)
|
||||
(expect (= win 2)))
|
||||
|
||||
(let [s (observable.new {:foo {:bar {:baz 43}}})]
|
||||
(var win 0)
|
||||
;; multiple observers can live on same subtree
|
||||
(s:observe [:foo :bar] #(set win (+ win 1)))
|
||||
(s:observe [:foo :bar] #(set win (+ win 1)))
|
||||
(s:update [:foo :bar :baz] 42)
|
||||
(expect (= win 2)))
|
||||
|
@ -21,7 +21,7 @@
|
||||
(let [el (get data self path)]
|
||||
(when el
|
||||
(if el._subscribers
|
||||
(el._subscribers:insert fun)
|
||||
(table.insert el._subscribers fun)
|
||||
(tset el :_subscribers [fun])))))
|
||||
|
||||
(fn new [data]
|
||||
|
Loading…
Reference in New Issue
Block a user