Last active
December 18, 2015 11:45
-
-
Save nblumoe/e937103389d0173f887f 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
;; example for novelty: | |
{:user/verify {:db/id 1234 :being-verified false :verification-error :credentials-invalid}} | |
(defn merge-tree [old-state novelty] | |
(cond | |
(:user/verify novelty) | |
(let [novelty-props (:user/verify novelty)] | |
(update-in old-state [:users/by-id (:db/id novelty-props)] merge (dissoc novelty-props :db/id))) | |
(map? old-state) | |
(merge old-state novelty) | |
:else | |
novelty)) | |
(defmethod mutate 'user/verify | |
[{:as env :keys [ref state reconciler]} _ _] | |
{:value {:keys [:users/list]} ;; problably not needed, users have Ident | |
:action #(swap! state update-in ref merge {:being-verified true}) ;; triggering local change | |
:rest-remote true}) ;; response gets merged into app-state, but no re-rendering is triggered |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment