-
-
Save ninjudd/1299885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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? | |
(let [layer (layer layer-name)] | |
(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#)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(with-txn :foo | |
(assoc-node "1" node2) | |
(update-node "1" assoc :baz [1 2 3]) | |
(update-node "1" dissoc :baz)) | |
(txn-> :foo | |
(assoc-node "1" node2) | |
(update-node "1" assoc :baz [1 2 3]) | |
(update-node "1" dissoc :baz)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment