          ; do nothing, only for a demo
          :sample-action model
 
-         [:set-visibility key]
-         (assoc model :visibility key)
-
          [:update-field val]
          (assoc model :field val)
 

         (-remove-todos model :completed?)))

;;;;;;;;;;;;;;;;;;;;;;;; View model
(defn view-model
  [model]
  ; reactions are extracted for better perfromance, e.g.:
  ; when input field changes most reactions will not be recalculated,
  ; because todos stay the same
  (let [todos (reaction (:todos @model))
        visibility (reaction (:visibility @model))]
    (-> model
        (ui/track-keys [:field :visibility])
        (assoc :has-todos? (reaction (-> @todos count pos?))
               :todos (reaction (filter (case @visibility
                                          :all (constantly true)
                                          :active (complement :completed?)


(defn init
  []
  {:field   ""
   ; list of maps
   :todos   (list (-init-todo 1 "Finish this project")
                  (-init-todo 2 "Take a bath"))
   :next-id 3})

(defn -update-todos*
  [model pred f & args]
