Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns freactive-sandbox.core-test
- (:require-macros [freactive.macros :refer [rx]])
- (:require [freactive.core :refer [atom cursor]]))
- (enable-console-print!)
- (def x (atom {:a 1 :b {:c 2 :d 3}}))
- (def b (cursor x
- (fn [x] (:b x))
- (fn [x b] (assoc x :b b))))
- (def c (cursor b
- (fn [x] (:c x))
- (fn [x c] (assoc x :c c))))
- (def cd (cursor b
- (fn [x] [(:c x) (:d x)])
- (fn [x [c d]] (assoc x :c c
- :d d))))
- (add-watch cd :cd (fn [k r o n]
- (println "cd" o n)))
- (def c*d (rx (let [[c d] @cd] (* c d))))
- (println "Initial c*d" @c*d)
- (add-watch c*d :c*d (fn [k r o n]
- (println "c*d" o n)))
- (reset! cd [4 5])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement