          :duration (reduce #(+ %1 (first %2)) 0 (:stdout asciicast))
          :frames (build-v1-frames asciicast)))
 
-(defmethod initialize-asciicast :default [dispatch state asciicast]
+(defmethod initialize-asciicast :default [state asciicast]
   (throw (str "unsupported asciicast version: " (:version asciicast))))
 
 (defn handle-asciicast-response
   "Merges asciicast frames into player state, hides loading indicator and starts the
   playback."
-  [state dispatch [json]]
-  (dispatch [:toggle-play])
+  [state [json]]
+  (dispatch state [:toggle-play])
   (let [asciicast (-> json
                       js/JSON.parse
                       (util/faster-js->clj :keywordize-keys true))]
-    (initialize-asciicast dispatch state asciicast)))
-
-(defn handle-bad-response [state dispatch resp]
+    (initialize-asciicast state asciicast)))
+
+(defn handle-bad-response [state resp]
   (print "error fetching asciicast file:")
   (prn resp)
   (assoc state :loading false))
 
 (defn handle-update-state
   "Applies given function (with args) to the player state."
-  [state _ [f & args]]
+  [state [f & args]]
   (apply f state args))
 
 (def event-handlers {:toggle-play handle-toggle-play

                        (assoc :current-time new-time :start-at new-time)
                        (update-screen screen-state))]
      (if playing?
        (start-playback new-state dispatch)
        new-state))))

(defn handle-rewind
  "Rewinds the playback by 5 seconds."
  [state dispatch]
  (let [position (new-position (:current-time state) (:duration state) -5)]
    (handle-seek state dispatch [position])))

(defn handle-fast-forward
  "Fast-forwards the playback by 5 seconds."
  [state dispatch]
  (let [position (new-position (:current-time state) (:duration state) 5)]
    (handle-seek state dispatch [position])))

(defn handle-finished
  "Prepares player to be ready for playback from the beginning. Starts the
  playback immediately when loop option is true."
  [state dispatch]
  (when (:loop state)
    (dispatch [:toggle-play]))
  (-> state
      (dissoc :stop)
      (assoc :start-at 0)

  "The heart of the player. Coordinates dispatching of state update events like
  terminal line updating, time reporting and cursor blinking.
  Returns function which stops the playback and returns time of the playback."
  [state]
  (let [start (js/Date.)
        start-at (:start-at state)
        speed (:speed state)
