diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/concurrency/stm.lux | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index cc609a055..4e2d82905 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -43,17 +43,19 @@ (wrap [])) (write! new-value (@abstraction var))))) - (def: #export (follow (^@representation target)) + (def: (helper|follow var) + (All [a] (-> (Var a) (frp.Channel a))) + (frp.channel [])) + (def: #export (follow target) {#.doc "Creates a channel that will receive all changes to the value of the given var."} (All [a] (-> (Var a) (IO (frp.Channel a)))) - (let [channel (: (frp.Channel ($ +0)) (frp.channel [])) - ## channel (frp.channel) - ] - (do io.Monad<IO> - [_ (atom.update (function [[value observers]] - [value (#.Cons (frp.publish channel) observers)]) - target)] - (wrap channel)))) + (do io.Monad<IO> + [#let [channel (helper|follow target) + target (@representation target)] + _ (atom.update (function [[value observers]] + [value (#.Cons (frp.publish channel) observers)]) + target)] + (wrap channel))) ) (type: (Tx-Frame a) |