diff --git a/src/clojure/freactive/dom.cljs b/src/clojure/freactive/dom.cljs index a9efb19..4bebbab 100644 --- a/src/clojure/freactive/dom.cljs +++ b/src/clojure/freactive/dom.cljs @@ -5,6 +5,9 @@ ;; ## Core Defintions +(def ^:dynamic *listen!* #(.addEventListener %1 %2 %3)) +(def ^:dynamic *unlisten!* #(.removeEventListener %1 %2 %3)) + (defonce ^:private auto-node-id 0) (defonce ^:private element-state-lookup #js {}) @@ -276,10 +279,10 @@ (setter attr-value)))) (defn listen! [element evt-name handler] - (.addEventListener element evt-name handler)) + (*listen!* element evt-name handler)) (defn remove-event-listener! [element evt-name handler] - (.removeEventListener element evt-name handler)) + (*unlisten!* element evt-name handler)) (defn- do-set-data-state! [element state] (set-attr! element "data-state" state)) diff --git a/src/clojure/freactive/plugins/goog_events.cljs b/src/clojure/freactive/plugins/goog_events.cljs new file mode 100644 index 0000000..39804b2 --- /dev/null +++ b/src/clojure/freactive/plugins/goog_events.cljs @@ -0,0 +1,7 @@ +(ns freactive.plugins.goog-events + (:require [goog.events :as events] + [freactive.dom :as dom])) + +(defn plug-in! [] + (set! dom/*listen!* events/listen) + (set! dom/*unlisten!* events/unlisten))