Skip to content

Instantly share code, notes, and snippets.

@jwdevantier
Created August 31, 2016 13:47
Show Gist options
  • Save jwdevantier/451205b3a0b9590524f4b046dcc95040 to your computer and use it in GitHub Desktop.
Save jwdevantier/451205b3a0b9590524f4b046dcc95040 to your computer and use it in GitHub Desktop.
(defn- filter-todos
[todos current-filter]
(case current-filter
"SHOW_ALL" todos
"SHOW_ACTIVE" (filter #(false? (:completed %1)) todos)
"SHOW_COMPLETED" (filter #(true? (:completed %1)) todos)))
(defn- visible-todos-query
[state [query-id]]
(println "visible-todos-query called")
(assert (= query-id :visible-todos))
;; "flatten", from
;; {:todos {:todos x :next-todo-id y} :filter z}
(reaction (-> (get-in @state [:todos :todos])
(filter-todos (:filter @state)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment