File tree Expand file tree Collapse file tree 3 files changed +0
-24
lines changed
examples/todomvc/src/todomvc Expand file tree Collapse file tree 3 files changed +0
-24
lines changed Original file line number Diff line number Diff line change 207207 (reduce #(assoc-in %1 [%2 :done ] new-done)
208208 todos
209209 (keys todos)))))
210-
211- ; ; TODO: I'd like to do this.
212- ; ; I think it requires the :alpha subscription to have a :set method.
213- #_(reg :event :toggle-alpha :<- :alpha? :-> not)
214-
215- (reg-event-db
216- :toggle-alpha
217- (fn [db _]
218- ; ; don't need to know the path any more.
219- ; ; can compute the sub instead.
220- ; ; it's memory-safe.
221- (let [alpha? @(sub :alpha? )]
222- ; ; still need to know the path to update the value.
223- (update-in db [:very :long :path :alpha? ] not))))
Original file line number Diff line number Diff line change 160160 :<- [:completed-count ]
161161 (fn [[todos completed] _]
162162 [(- (count todos) completed) completed]))
163-
164- (reg :sub :alpha? :-> (comp :alpha? :path :long :very ))
Original file line number Diff line number Diff line change 9191 :on-save #(when (seq %)
9292 (dispatch [:add-todo %]))}]])
9393
94- (defn alpha []
95- (let [alpha? @(sub :alpha? )]
96- [:a {:href " #"
97- :style {:color (if alpha? " red" " gray" )}
98- :on-click #(dispatch [:toggle-alpha ])}
99- (if alpha? " alpha is running!" " try alpha?" )]))
100-
10194(defn todo-app
10295 []
10396 [:<>
104- [alpha]
10597 [:section#todoapp
10698 [task-entry]
10799 (when (seq @(subscribe [:todos ]))
You can’t perform that action at this time.
0 commit comments