Merge pull request #288 from reagent-project/deftype-constrcutors

Deftype constrcutors
This commit is contained in:
Juho Teperi 2017-03-11 01:28:23 +02:00 committed by GitHub
commit ccb94f5274
5 changed files with 12 additions and 11 deletions

View File

@ -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)

View File

@ -18,6 +18,7 @@
:profiles {:test {:cljsbuild
{:builds {:client {:source-paths ["test"]
:notify-command ["node" "bin/gen-site.js"]
:compiler
{:main "reagenttest.runtests"}}}}}

View File

@ -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))

View File

@ -254,7 +254,7 @@
($ util/react createElement c jsprops)))
(defn adapt-react-class [c]
(doto (NativeWrapper.)
(doto (->NativeWrapper)
($! :name c)
($! :id nil)
($! :class nil)))

View File

@ -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))