-
-
Save 6ewis/9606ca4933b3d3169b0e2178842aa4a2 to your computer and use it in GitHub Desktop.
What's going on at line 5 [db _] , something is being ignored '_'(does it have to). what is being ignored? | what's going on at line 11- what's path for?is it related to clojure.zip/path
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
(register-handler ;; setup initial state | |
:initialize ;; usage: (dispatch [:initialize]) | |
(fn | |
[db _] | |
(merge db initial-state))) ;; what it returns becomes the new state | |
(register-handler | |
:time-color ;; usage: (dispatch [:time-color 34562]) | |
(path [:time-color]) ;; this is middleware | |
(fn | |
[time-color [_ value]] ;; path middleware adjusts the first parameter | |
value)) | |
(register-handler | |
:timer | |
(fn | |
;; the first item in the second argument is :timer the second is the | |
;; new value | |
[db [_ value]] | |
(assoc db :timer value))) ;; return the new version of db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment