   [event-bus]
   (fn [f x m]
     (let [parent-bus (or
-                       (and om/*parent* (om/get-state om/*parent* ::event-bus))
+                       (and *parent* (om/get-state *parent* ::event-bus))
                        event-bus)]
       (om/build* f x (update-in m [:init-state] merge {::event-bus parent-bus})))))
 

  (:require [om.core :as om :include-macros true]
            [cljs.core.async :as async])
  (:require-macros [cljs.core.async.macros :as async]))

;; =============================================================================
;; Event handling protocol. Use it in your components if you're interested

                                   (f this (fn []
                                             (.call prev-method this)))))))))

(defn- extend-pure-methods
  "Given pure methods and a map of overrides, it extends pure methods with new lifecycle methods.

  Example:

  (extend-pure-methods
    {:render
    (fn [this super]
      ;; Do something.
      (super))}) ;; Call the original method.

  You can also specify a map of pure methods as the first argument."
  ([new-methods]
    (extend-pure-methods om/pure-methods new-methods))
  ([methods new-methods]
    (println (seq new-methods))
    (loop [methods' methods [[new-method-name new-method-fn] & new-methods'] (seq new-methods)]
      (if new-method-name
        (recur (around-method! new-method-name methods' new-method-fn) new-methods')
        methods'))))

(defn- make-descriptor
  "Creates a custom descriptor with support for an event bus."
  [new-methods]
  (let [methods (extend-pure-methods new-methods)
        descriptor (om/specify-state-methods! (clj->js methods))]
    descriptor))

