Skip to content

Instantly share code, notes, and snippets.

@alexanderjamesking
Created November 26, 2021 10:33
Show Gist options
  • Save alexanderjamesking/1d6e724ccab4d5d600e8baac3270781b to your computer and use it in GitHub Desktop.
Save alexanderjamesking/1d6e724ccab4d5d600e8baac3270781b to your computer and use it in GitHub Desktop.
(defn task-list []
(let [visible-todos @(subscribe [:visible-todos])
all-complete? @(subscribe [:all-complete?])]
[:section#main
[:input#toggle-all
{:type "checkbox"
:checked all-complete?
:on-change #(dispatch [:complete-all-toggle])}]
[:label
{:for "toggle-all"}
"Mark all as complete"]
[:ul#todo-list
(for [todo visible-todos]
^{:key (:id todo)} [todo-item todo])]]))
(defn task-list
[{:keys [visible-todos all-complete? complete-all]}]
[:section#main
[:input#toggle-all
{:type "checkbox"
:checked all-complete?
:on-change complete-all}]
[:label
{:for "toggle-all"}
"Mark all as complete"]
[:ul#todo-list
(for [todo visible-todos]
^{:key (:id todo)} [todo-item todo])]])
(defn rf-task-list []
[task-list {:visible-todos @(subscribe [:visible-todos])
:all-complete? @(subscribe [:all-complete?])
:complete-all #(dispatch [:complete-all-toggle])}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment