Skip to content

Instantly share code, notes, and snippets.

@sparkofreason
Last active August 29, 2015 14:23
Show Gist options
  • Save sparkofreason/25845cd249af4188a75f to your computer and use it in GitHub Desktop.
Save sparkofreason/25845cd249af4188a75f to your computer and use it in GitHub Desktop.
Inconsistencies in freactive lens-cursor and cursor behavior
(ns freactive-sandbox.rx-test
(:require-macros [freactive.macros :refer [rx debug-rx]])
(:require [freactive.core :refer [atom cursor lens-cursor]]
[freactive.dom :as dom]))
(enable-console-print!)
(def state (atom {:a 1 :b {:c 2 :d 3}}))
(def lc
(lens-cursor state :b))
(println "lc:" @lc)
(def b1 (cursor lc :c))
(add-watch b1 :b1 #(println "b(cursor):" %4))
(def b2 (lens-cursor lc :c))
(add-watch b2 :b2 #(println "b(lens-cursor):" %4))
(assoc! state :b {:c "(assoc! state :b {:c ...})"})
(reset! state {:a 2 :b {:c "(reset! state {:a 2 :b {:c ...}})"}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment