Skip to content

Instantly share code, notes, and snippets.

@6ewis
Created May 27, 2016 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 6ewis/9606ca4933b3d3169b0e2178842aa4a2 to your computer and use it in GitHub Desktop.
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
(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