 
 (defn main [initial-model view update]
   (go-loop [model initial-model]
-           (println model)
            (q/render (view model) root)
-           (recur (update model (<! messages)))))
+           (let [message (<! messages)
+                 [updated-model effect] (update model message)]
+             (printaction message model updated-model effect)
+             (if-not (nil? effect) (>! effects effect))
+             (recur updated-model))))
 
 ;; ******************************************************************
 


(def messages (chan))

(def root (.getElementById js/document "app"))

(defn submit [message]

(defrecord Increment []
  Action
  (run [this model]
    [(update model :counter inc) nil]))

(defrecord Decrement []
  Action
  (run [this model]
    [(update model :counter dec) nil]))

(defrecord SetCounter [value]
  Action
  (run [this model]
    [(assoc model :counter value) nil]))

(defrecord GenerateRandom []
  Action
  (run [this model]
    [model (->Random ->SetCounter)]))

(defrecord PrintSomething []
  Action
  (run [this model]
    [model (->Print)]))

(defrecord Type [text]
  Action
  (run [this model]
    [(assoc model :text (:text this)) nil]))

(defn view [model]
  (d/div {}
