From 82c4013a297a953d67dce0bc6aa69359cd0c8729 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Sat, 11 Mar 2017 01:19:35 +0200 Subject: [PATCH] Use deftype constrcutor functions instead of interop, replaces #144 --- examples/geometry/src/geometry/geometry.cljs | 4 ++-- src/reagent/impl/batching.cljs | 2 +- src/reagent/impl/template.cljs | 2 +- src/reagent/ratom.cljs | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/geometry/src/geometry/geometry.cljs b/examples/geometry/src/geometry/geometry.cljs index c81eccb..d2fcbe3 100644 --- a/examples/geometry/src/geometry/geometry.cljs +++ b/examples/geometry/src/geometry/geometry.cljs @@ -1,6 +1,6 @@ (ns geometry.geometry) -(defprotocol IPoint +(defprotocol IPoint (x [p]) (y [p])) @@ -10,7 +10,7 @@ (y [_] y-coord)) (defn point [x y] - (Point. x y)) + (->Point x y)) (defn dist [p1 p2] (js/Math.sqrt (+ (js/Math.pow (- (x p2) (x p1)) 2) diff --git a/src/reagent/impl/batching.cljs b/src/reagent/impl/batching.cljs index 646047f..3249049 100644 --- a/src/reagent/impl/batching.cljs +++ b/src/reagent/impl/batching.cljs @@ -86,7 +86,7 @@ (run-queue cs)) (.flush-after-render this))) -(defonce render-queue (RenderQueue. false)) +(defonce render-queue (->RenderQueue false)) (defn flush [] (.flush-queues render-queue)) diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index 17e3a9f..34d8bc5 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -254,7 +254,7 @@ ($ util/react createElement c jsprops))) (defn adapt-react-class [c] - (doto (NativeWrapper.) + (doto (->NativeWrapper) ($! :name c) ($! :id nil) ($! :class nil))) diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index 8f50bb8..53e2f29 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -162,8 +162,8 @@ (defn atom "Like clojure.core/atom, except that it keeps track of derefs." - ([x] (RAtom. x nil nil nil)) - ([x & {:keys [meta validator]}] (RAtom. x meta validator nil))) + ([x] (->RAtom x nil nil nil)) + ([x & {:keys [meta validator]}] (->RAtom x meta validator nil))) ;;; track @@ -306,7 +306,7 @@ (not (vector? src)))) (str "src must be a reactive atom or a function, not " (pr-str src))) - (RCursor. src path nil nil nil)) + (->RCursor src path nil nil nil)) ;;; with-let support @@ -486,7 +486,7 @@ (defn make-reaction [f & {:keys [auto-run on-set on-dispose]}] - (let [reaction (Reaction. f nil true false nil nil nil nil)] + (let [reaction (->Reaction f nil true false nil nil nil nil)] (._set-opts reaction {:auto-run auto-run :on-set on-set :on-dispose on-dispose}) @@ -563,9 +563,9 @@ (-pr-writer [a w opts] (pr-atom a w opts "Wrap:"))) (defn make-wrapper [value callback-fn args] - (Wrapper. value - (util/partial-ifn. callback-fn args nil) - false nil)) + (->Wrapper value + (util/->partial-ifn callback-fn args nil) + false nil))