             transitions)
        (apply concat)))
 
+(defn- get-component-unit [{:keys [ruleset] :as router} component]
+  (-> (:units ruleset)
+      owc/map-invert-coll
+      component))
+
 (defn- handle-events [eventhandlers msg]
   (reduce (fn [s [key eventhandler]]
             (if-let [nextfs (next->fns eventhandler)]

         ::transition-count 0
         ::max-transitions max-transitions))

(defn dispatch [msg]
  (let [component (peek (::component msg))]
    (cond (fn? component)                   [true  (component msg)]
          (satisfies? ap/Channel component) [true  (a/put! component msg)]

           :evmsgs []}
          eventhandlers))

(defn advance [{:keys [unit ruleset] :as router} msg]
  "Takes a message, runs it against ruleset and returns a sequence of routed messages."
  (debug "routing starting with" (printable-msg msg))
  (if (< (::transition-count msg) 100)
