Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created October 19, 2011 22:18
Show Gist options
  • Save amalloy/1299853 to your computer and use it in GitHub Desktop.
Save amalloy/1299853 to your computer and use it in GitHub Desktop.
(is (= (assoc node2 :id "1")
(-> layer-name
(write-txn (assoc-node "1" node2)
(update-node "1" assoc :baz [1 2 3])
(update-node "1" dissoc :baz))
(get-node "1"))))
;; the above is sugar for the below. seem useful?
(dotxn layer
(-> layer
(assoc-node "1" node2)
(update-node "1" assoc :baz [1 2 3])
(update-node "1" dissoc :baz)))
(is (= (assoc node2 :id "1") (get-node layer-name "1")))
;; implementation:
(defmacro write-txn [layer-name & actions]
`(let [layer-name# ~layer-name
layer# (layer layer-name#)]
(retro/dotxn layer#
(-> layer#
~@actions))
layer-name#))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment