Update bundled versions of re-frame and reagent

This commit is contained in:
Daniel Compton 2018-01-25 15:13:21 +13:00
parent afd847eddb
commit 532657a44a
29 changed files with 245 additions and 177 deletions

View File

@ -1,6 +1,12 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## Unreleased
### Changed
* Updated bundled re-frame version to 0.10.3, and bundled reagent version to 0.7.0. This shouldn't impact your project's dependencies as they are source bundled via [mranderson](https://github.com/benedekfazekas/mranderson).
## [0.1.15] - 2018-01-24 ## [0.1.15] - 2018-01-24
### Added ### Added

View File

@ -5,7 +5,7 @@
:dependencies [[org.clojure/clojure "1.9.0"] :dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.9.671"] [org.clojure/clojurescript "1.9.671"]
[reagent "0.6.0" :scope "provided"] [reagent "0.6.0" :scope "provided"]
[re-frame "0.10.3-alpha2" :scope "provided"] [re-frame "0.10.3" :scope "provided"]
[binaryage/devtools "0.9.4"] [binaryage/devtools "0.9.4"]
[garden "1.3.3"] [garden "1.3.3"]
[cljsjs/react-flip-move "2.9.17-0"]] [cljsjs/react-flip-move "2.9.17-0"]]
@ -31,7 +31,7 @@
:target-path "resources/day8/re_frame/trace"} :target-path "resources/day8/re_frame/trace"}
:profiles {:dev {:dependencies [[binaryage/dirac "RELEASE"]]} :profiles {:dev {:dependencies [[binaryage/dirac "RELEASE"]]}
:mranderson {:dependencies ^:replace [^:source-dep [re-frame "0.10.2" :mranderson {:dependencies ^:replace [^:source-dep [re-frame "0.10.3"
:exclusions [org.clojure/clojurescript :exclusions [org.clojure/clojurescript
cljsjs/react cljsjs/react
cljsjs/react-dom cljsjs/react-dom

View File

@ -2,6 +2,7 @@
lein do clean lein do clean
lein with-profile mranderson source-deps lein with-profile mranderson source-deps
cp -r target/srcdeps/mranderson047 src
# Then delete the META-INF directories # Then delete the META-INF directories
rm -r target/srcdeps/mranderson047/reagent/v0v7v0/META-INF
rm -r target/srcdeps/mranderson047/re-frame
cp -r target/srcdeps/mranderson047 src

View File

@ -22,7 +22,7 @@
[re-frame.interop :as interop] [re-frame.interop :as interop]
[devtools.formatters.core :as devtools] [devtools.formatters.core :as devtools]
[mranderson047.re-frame.v0v10v2.re-frame.core :as rf] [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[mranderson047.reagent.v0v6v0.reagent.core :as r])) [mranderson047.reagent.v0v7v0.reagent.core :as r]))
(goog-define debug? false) (goog-define debug? false)

View File

@ -1,6 +1,7 @@
(ns day8.re-frame.trace.events (ns day8.re-frame.trace.events
(:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf] (:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[mranderson047.reagent.v0v6v0.reagent.core :as r] [mranderson047.reagent.v0v7v0.reagent.core :as r]
[cljs.tools.reader.edn]
[day8.re-frame.trace.utils.utils :as utils] [day8.re-frame.trace.utils.utils :as utils]
[day8.re-frame.trace.utils.localstorage :as localstorage] [day8.re-frame.trace.utils.localstorage :as localstorage]
[clojure.string :as str] [clojure.string :as str]

View File

@ -18,7 +18,7 @@
see additional properties that can be specified in options see additional properties that can be specified in options
https://github.com/joshwcomeau/react-flip-move#options" https://github.com/joshwcomeau/react-flip-move#options"
(:require (:require
[mranderson047.reagent.v0v6v0.reagent.core :as reagent] [mranderson047.reagent.v0v7v0.reagent.core :as reagent]
[cljsjs.react-flip-move])) [cljsjs.react-flip-move]))
(def component (def component

View File

@ -1,7 +1,7 @@
(ns day8.re-frame.trace.utils.re-com (ns day8.re-frame.trace.utils.re-com
"Shameless pilfered from re-com." "Shameless pilfered from re-com."
(:require-macros [day8.re-frame.trace.utils.re-com :refer [handler-fn]]) (:require-macros [day8.re-frame.trace.utils.re-com :refer [handler-fn]])
(:require [mranderson047.reagent.v0v6v0.reagent.ratom :as reagent :refer [RAtom Reaction RCursor Track Wrapper]] (:require [mranderson047.reagent.v0v7v0.reagent.ratom :as reagent :refer [RAtom Reaction RCursor Track Wrapper]]
[clojure.string :as string])) [clojure.string :as string]))
(defn px (defn px

View File

@ -5,7 +5,7 @@
[day8.re-frame.trace.utils.animated :as animated] [day8.re-frame.trace.utils.animated :as animated]
[day8.re-frame.trace.view.components :as components] [day8.re-frame.trace.view.components :as components]
[mranderson047.re-frame.v0v10v2.re-frame.core :as rf] [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[mranderson047.reagent.v0v6v0.reagent.core :as r] [mranderson047.reagent.v0v7v0.reagent.core :as r]
[day8.re-frame.trace.utils.re-com :as rc :refer [css-join]] [day8.re-frame.trace.utils.re-com :as rc :refer [css-join]]
[day8.re-frame.trace.common-styles :as common] [day8.re-frame.trace.common-styles :as common]
[clojure.data]) [clojure.data])

View File

@ -5,7 +5,7 @@
[day8.re-frame.trace.utils.localstorage :as localstorage] [day8.re-frame.trace.utils.localstorage :as localstorage]
[clojure.string :as str] [clojure.string :as str]
[day8.re-frame.trace.utils.re-com :as rc] [day8.re-frame.trace.utils.re-com :as rc]
[mranderson047.reagent.v0v6v0.reagent.core :as r]) [mranderson047.reagent.v0v7v0.reagent.core :as r])
(:require-macros [day8.re-frame.trace.utils.macros :refer [with-cljs-devtools-prefs]])) (:require-macros [day8.re-frame.trace.utils.macros :refer [with-cljs-devtools-prefs]]))
(defn search-input [{:keys [title placeholder on-save on-change on-stop]}] (defn search-input [{:keys [title placeholder on-save on-change on-stop]}]

View File

@ -1,6 +1,6 @@
(ns day8.re-frame.trace.view.settings (ns day8.re-frame.trace.view.settings
(:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf] (:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[mranderson047.reagent.v0v6v0.reagent.core :as r] [mranderson047.reagent.v0v7v0.reagent.core :as r]
[day8.re-frame.trace.utils.re-com :as rc :refer [css-join]] [day8.re-frame.trace.utils.re-com :as rc :refer [css-join]]
[day8.re-frame.trace.common-styles :as common] [day8.re-frame.trace.common-styles :as common]
[garden.units :as units] [garden.units :as units]

View File

@ -3,7 +3,7 @@
[day8.re-frame.trace.utils.utils :as utils] [day8.re-frame.trace.utils.utils :as utils]
[day8.re-frame.trace.utils.animated :as animated] [day8.re-frame.trace.utils.animated :as animated]
[mranderson047.re-frame.v0v10v2.re-frame.core :as rf] [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[mranderson047.reagent.v0v6v0.reagent.core :as r] [mranderson047.reagent.v0v7v0.reagent.core :as r]
[day8.re-frame.trace.utils.re-com :as rc :refer [css-join]] [day8.re-frame.trace.utils.re-com :as rc :refer [css-join]]
[day8.re-frame.trace.common-styles :as common] [day8.re-frame.trace.common-styles :as common]
[day8.re-frame.trace.view.components :as components]) [day8.re-frame.trace.view.components :as components])

View File

@ -6,7 +6,7 @@
[day8.re-frame.trace.utils.localstorage :as localstorage] [day8.re-frame.trace.utils.localstorage :as localstorage]
[cljs.pprint :as pprint] [cljs.pprint :as pprint]
[clojure.set :as set] [clojure.set :as set]
[mranderson047.reagent.v0v6v0.reagent.core :as r] [mranderson047.reagent.v0v7v0.reagent.core :as r]
[mranderson047.re-frame.v0v10v2.re-frame.core :as rf] [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[day8.re-frame.trace.utils.re-com :as rc])) [day8.re-frame.trace.utils.re-com :as rc]))

View File

@ -48,7 +48,7 @@
(defn make-reaction (defn make-reaction
"On JVM Clojure, return a `deref`-able thing which invokes the given function "On JVM Clojure, return a `deref`-able thing which invokes the given function
on every `deref`. That is, `make-reaction` here provides precisely none of the on every `deref`. That is, `make-reaction` here provides precisely none of the
benefits of `mranderson047.reagent.v0v6v0.reagent.ratom/make-reaction` (which only invokes its function if benefits of `mranderson047.reagent.v0v7v0.reagent.ratom/make-reaction` (which only invokes its function if
the reactions that the function derefs have changed value). But so long as `f` the reactions that the function derefs have changed value). But so long as `f`
only depends on other reactions (which also behave themselves), the only only depends on other reactions (which also behave themselves), the only
difference is one of efficiency. That is, your tests should see no difference difference is one of efficiency. That is, your tests should see no difference

View File

@ -1,13 +1,13 @@
(ns mranderson047.re-frame.v0v10v2.re-frame.interop (ns mranderson047.re-frame.v0v10v2.re-frame.interop
(:require [goog.async.nextTick] (:require [goog.async.nextTick]
[mranderson047.reagent.v0v6v0.reagent.core] [mranderson047.reagent.v0v7v0.reagent.core]
[mranderson047.reagent.v0v6v0.reagent.ratom])) [mranderson047.reagent.v0v7v0.reagent.ratom]))
(def next-tick goog.async.nextTick) (def next-tick goog.async.nextTick)
(def empty-queue #queue []) (def empty-queue #queue [])
(def after-render mranderson047.reagent.v0v6v0.reagent.core/after-render) (def after-render mranderson047.reagent.v0v7v0.reagent.core/after-render)
;; Make sure the Google Closure compiler sees this as a boolean constant, ;; Make sure the Google Closure compiler sees this as a boolean constant,
;; otherwise Dead Code Elimination won't happen in `:advanced` builds. ;; otherwise Dead Code Elimination won't happen in `:advanced` builds.
@ -16,23 +16,23 @@
(def ^boolean debug-enabled? "@define {boolean}" ^boolean js/goog.DEBUG) (def ^boolean debug-enabled? "@define {boolean}" ^boolean js/goog.DEBUG)
(defn ratom [x] (defn ratom [x]
(mranderson047.reagent.v0v6v0.reagent.core/atom x)) (mranderson047.reagent.v0v7v0.reagent.core/atom x))
(defn ratom? [x] (defn ratom? [x]
(satisfies? mranderson047.reagent.v0v6v0.reagent.ratom/IReactiveAtom x)) (satisfies? mranderson047.reagent.v0v7v0.reagent.ratom/IReactiveAtom x))
(defn deref? [x] (defn deref? [x]
(satisfies? IDeref x)) (satisfies? IDeref x))
(defn make-reaction [f] (defn make-reaction [f]
(mranderson047.reagent.v0v6v0.reagent.ratom/make-reaction f)) (mranderson047.reagent.v0v7v0.reagent.ratom/make-reaction f))
(defn add-on-dispose! [a-ratom f] (defn add-on-dispose! [a-ratom f]
(mranderson047.reagent.v0v6v0.reagent.ratom/add-on-dispose! a-ratom f)) (mranderson047.reagent.v0v7v0.reagent.ratom/add-on-dispose! a-ratom f))
(defn dispose! [a-ratom] (defn dispose! [a-ratom]
(mranderson047.reagent.v0v6v0.reagent.ratom/dispose! a-ratom)) (mranderson047.reagent.v0v7v0.reagent.ratom/dispose! a-ratom))
(defn set-timeout! [f ms] (defn set-timeout! [f ms]
(js/setTimeout f ms)) (js/setTimeout f ms))
@ -46,11 +46,11 @@
"Produces an id for reactive Reagent values "Produces an id for reactive Reagent values
e.g. reactions, ratoms, cursors." e.g. reactions, ratoms, cursors."
[reactive-val] [reactive-val]
(when (implements? mranderson047.reagent.v0v6v0.reagent.ratom/IReactiveAtom reactive-val) (when (implements? mranderson047.reagent.v0v7v0.reagent.ratom/IReactiveAtom reactive-val)
(str (condp instance? reactive-val (str (condp instance? reactive-val
mranderson047.reagent.v0v6v0.reagent.ratom/RAtom "ra" mranderson047.reagent.v0v7v0.reagent.ratom/RAtom "ra"
mranderson047.reagent.v0v6v0.reagent.ratom/RCursor "rc" mranderson047.reagent.v0v7v0.reagent.ratom/RCursor "rc"
mranderson047.reagent.v0v6v0.reagent.ratom/Reaction "rx" mranderson047.reagent.v0v7v0.reagent.ratom/Reaction "rx"
mranderson047.reagent.v0v6v0.reagent.ratom/Track "tr" mranderson047.reagent.v0v7v0.reagent.ratom/Track "tr"
"other") "other")
(hash reactive-val)))) (hash reactive-val))))

View File

@ -1,2 +0,0 @@
(ns mranderson047.reagent.v0v6v0.reagent.interop
(:require-macros [mranderson047.reagent.v0v6v0.reagent.interop]))

View File

@ -1,5 +1,5 @@
(ns mranderson047.reagent.v0v6v0.reagent.core (ns mranderson047.reagent.v0v7v0.reagent.core
(:require [mranderson047.reagent.v0v6v0.reagent.ratom :as ra])) (:require [mranderson047.reagent.v0v7v0.reagent.ratom :as ra]))
(defmacro with-let [bindings & body] (defmacro with-let [bindings & body]
"Bind variables as with let, except that when used in a component "Bind variables as with let, except that when used in a component

View File

@ -1,15 +1,17 @@
(ns mranderson047.reagent.v0v6v0.reagent.core (ns mranderson047.reagent.v0v7v0.reagent.core
(:require-macros [mranderson047.reagent.v0v6v0.reagent.core]) (:require-macros [mranderson047.reagent.v0v7v0.reagent.core])
(:refer-clojure :exclude [partial atom flush]) (:refer-clojure :exclude [partial atom flush])
(:require [mranderson047.reagent.v0v6v0.reagent.impl.template :as tmpl] (:require [mranderson047.reagent.v0v7v0.reagent.impl.template :as tmpl]
[mranderson047.reagent.v0v6v0.reagent.impl.component :as comp] [mranderson047.reagent.v0v7v0.reagent.impl.component :as comp]
[mranderson047.reagent.v0v6v0.reagent.impl.util :as util] [mranderson047.reagent.v0v7v0.reagent.impl.util :as util]
[mranderson047.reagent.v0v6v0.reagent.impl.batching :as batch] [mranderson047.reagent.v0v7v0.reagent.impl.batching :as batch]
[mranderson047.reagent.v0v6v0.reagent.ratom :as ratom] [mranderson047.reagent.v0v7v0.reagent.ratom :as ratom]
[mranderson047.reagent.v0v6v0.reagent.debug :as deb :refer-macros [dbg prn]] [mranderson047.reagent.v0v7v0.reagent.debug :as deb :refer-macros [dbg prn
[mranderson047.reagent.v0v6v0.reagent.interop :refer-macros [$ $!]] assert-some assert-component
[mranderson047.reagent.v0v6v0.reagent.dom :as dom] assert-js-object assert-new-state
[mranderson047.reagent.v0v6v0.reagent.dom.server :as server])) assert-callable]]
[mranderson047.reagent.v0v7v0.reagent.interop :refer-macros [$ $!]]
[mranderson047.reagent.v0v7v0.reagent.dom :as dom]))
(def is-client util/is-client) (def is-client util/is-client)
@ -31,13 +33,13 @@
([type] ([type]
(create-element type nil)) (create-element type nil))
([type props] ([type props]
(assert (not (map? props))) (assert-js-object props)
($ react createElement type props)) ($ react createElement type props))
([type props child] ([type props child]
(assert (not (map? props))) (assert-js-object props)
($ react createElement type props child)) ($ react createElement type props child))
([type props child & children] ([type props child & children]
(assert (not (map? props))) (assert-js-object props)
(apply ($ react :createElement) type props child children))) (apply ($ react :createElement) type props child children)))
(defn as-element (defn as-element
@ -50,7 +52,7 @@
"Returns an adapter for a native React class, that may be used "Returns an adapter for a native React class, that may be used
just like a Reagent component function or class in Hiccup forms." just like a Reagent component function or class in Hiccup forms."
[c] [c]
(assert c) (assert-some c "Component")
(tmpl/adapt-react-class c)) (tmpl/adapt-react-class c))
(defn reactify-component (defn reactify-component
@ -58,7 +60,7 @@
React, for example in JSX. A single argument, props, is passed to React, for example in JSX. A single argument, props, is passed to
the component, converted to a map." the component, converted to a map."
[c] [c]
(assert c) (assert-some c "Component")
(comp/reactify-component c)) (comp/reactify-component c))
(defn render (defn render
@ -79,20 +81,9 @@
[container] [container]
(dom/unmount-component-at-node container)) (dom/unmount-component-at-node container))
(defn render-to-string
"Turns a component into an HTML string."
[component]
(server/render-to-string component))
;; For backward compatibility ;; For backward compatibility
(def as-component as-element) (def as-component as-element)
(def render-component render) (def render-component render)
(def render-component-to-string render-to-string)
(defn render-to-static-markup
"Turns a component into an HTML string, without data-react-id attributes, etc."
[component]
(server/render-to-static-markup component))
(defn ^:export force-update-all (defn ^:export force-update-all
"Force re-rendering of all mounted Reagent components. This is "Force re-rendering of all mounted Reagent components. This is
@ -137,30 +128,30 @@
(defn state-atom (defn state-atom
"Returns an atom containing a components state." "Returns an atom containing a components state."
[this] [this]
(assert (comp/reagent-component? this)) (assert-component this)
(comp/state-atom this)) (comp/state-atom this))
(defn state (defn state
"Returns the state of a component, as set with replace-state or set-state. "Returns the state of a component, as set with replace-state or set-state.
Equivalent to (deref (r/state-atom this))" Equivalent to (deref (r/state-atom this))"
[this] [this]
(assert (comp/reagent-component? this)) (assert-component this)
(deref (state-atom this))) (deref (state-atom this)))
(defn replace-state (defn replace-state
"Set state of a component. "Set state of a component.
Equivalent to (reset! (state-atom this) new-state)" Equivalent to (reset! (state-atom this) new-state)"
[this new-state] [this new-state]
(assert (comp/reagent-component? this)) (assert-component this)
(assert (or (nil? new-state) (map? new-state))) (assert-new-state new-state)
(reset! (state-atom this) new-state)) (reset! (state-atom this) new-state))
(defn set-state (defn set-state
"Merge component state with new-state. "Merge component state with new-state.
Equivalent to (swap! (state-atom this) merge new-state)" Equivalent to (swap! (state-atom this) merge new-state)"
[this new-state] [this new-state]
(assert (comp/reagent-component? this)) (assert-component this)
(assert (or (nil? new-state) (map? new-state))) (assert-new-state new-state)
(swap! (state-atom this) merge new-state)) (swap! (state-atom this) merge new-state))
(defn force-update (defn force-update
@ -178,19 +169,19 @@
(defn props (defn props
"Returns the props passed to a component." "Returns the props passed to a component."
[this] [this]
(assert (comp/reagent-component? this)) (assert-component this)
(comp/get-props this)) (comp/get-props this))
(defn children (defn children
"Returns the children passed to a component." "Returns the children passed to a component."
[this] [this]
(assert (comp/reagent-component? this)) (assert-component this)
(comp/get-children this)) (comp/get-children this))
(defn argv (defn argv
"Returns the entire Hiccup form passed to the component." "Returns the entire Hiccup form passed to the component."
[this] [this]
(assert (comp/reagent-component? this)) (assert-component this)
(comp/get-argv this)) (comp/get-argv this))
(defn dom-node (defn dom-node
@ -269,7 +260,7 @@
Probably useful only for passing to child components." Probably useful only for passing to child components."
[value reset-fn & args] [value reset-fn & args]
(assert (ifn? reset-fn)) (assert-callable reset-fn)
(ratom/make-wrapper value reset-fn args)) (ratom/make-wrapper value reset-fn args))
@ -346,10 +337,9 @@
(batch/do-after-render f)) (batch/do-after-render f))
(defn partial (defn partial
"Works just like clojure.core/partial, except that it is an IFn, and "Works just like clojure.core/partial, but the result can be compared with ="
the result can be compared with ="
[f & args] [f & args]
(util/partial-ifn. f args nil)) (util/make-partial-fn f args))
(defn component-path (defn component-path
;; Try to return the path of component c as a string. ;; Try to return the path of component c as a string.

View File

@ -1,19 +1,19 @@
(ns mranderson047.reagent.v0v6v0.reagent.debug (ns mranderson047.reagent.v0v7v0.reagent.debug
(:refer-clojure :exclude [prn println time])) (:refer-clojure :exclude [prn println time]))
(defmacro log (defmacro log
"Print with console.log, if it exists." "Print with console.log, if it exists."
[& forms] [& forms]
`(when mranderson047.reagent.v0v6v0.reagent.debug.has-console `(when mranderson047.reagent.v0v7v0.reagent.debug.has-console
(.log js/console ~@forms))) (.log js/console ~@forms)))
(defmacro warn (defmacro warn
"Print with console.warn." "Print with console.warn."
[& forms] [& forms]
(when *assert* (when *assert*
`(when mranderson047.reagent.v0v6v0.reagent.debug.has-console `(when mranderson047.reagent.v0v7v0.reagent.debug.has-console
(.warn (if mranderson047.reagent.v0v6v0.reagent.debug.tracking (.warn (if mranderson047.reagent.v0v7v0.reagent.debug.tracking
mranderson047.reagent.v0v6v0.reagent.debug.track-console js/console) mranderson047.reagent.v0v7v0.reagent.debug.track-console js/console)
(str "Warning: " ~@forms))))) (str "Warning: " ~@forms)))))
(defmacro warn-unless (defmacro warn-unless
@ -26,9 +26,9 @@
"Print with console.error." "Print with console.error."
[& forms] [& forms]
(when *assert* (when *assert*
`(when mranderson047.reagent.v0v6v0.reagent.debug.has-console `(when mranderson047.reagent.v0v7v0.reagent.debug.has-console
(.error (if mranderson047.reagent.v0v6v0.reagent.debug.tracking (.error (if mranderson047.reagent.v0v7v0.reagent.debug.tracking
mranderson047.reagent.v0v6v0.reagent.debug.track-console js/console) mranderson047.reagent.v0v7v0.reagent.debug.track-console js/console)
(str ~@forms))))) (str ~@forms)))))
(defmacro println (defmacro println
@ -71,3 +71,26 @@ as well as package name and line number. Returns x."
~@forms)] ~@forms)]
(js/console.timeEnd label#) (js/console.timeEnd label#)
res#))) res#)))
(defmacro assert-some [value tag]
`(assert ~value (str ~tag " must not be nil")))
(defmacro assert-component [value]
`(assert (comp/reagent-component? ~value)
(str "Expected a mranderson047.reagent.v0v7v0.reagent component, not "
(pr-str ~value))))
(defmacro assert-js-object [value]
`(assert (not (map? ~value))
(str "Expected a JS object, not "
(pr-str ~value))))
(defmacro assert-new-state [value]
`(assert (or (nil? ~value) (map? ~value))
(str "Expected a valid new state, not "
(pr-str ~value))))
(defmacro assert-callable [value]
`(assert (ifn? ~value)
(str "Expected something callable, not "
(pr-str ~value))))

View File

@ -1,5 +1,5 @@
(ns mranderson047.reagent.v0v6v0.reagent.debug (ns mranderson047.reagent.v0v7v0.reagent.debug
(:require-macros [mranderson047.reagent.v0v6v0.reagent.debug])) (:require-macros [mranderson047.reagent.v0v7v0.reagent.debug]))
(def ^:const has-console (exists? js/console)) (def ^:const has-console (exists? js/console))

View File

@ -1,11 +1,11 @@
(ns mranderson047.reagent.v0v6v0.reagent.dom (ns mranderson047.reagent.v0v7v0.reagent.dom
(:require [cljsjs.react.dom] (:require [cljsjs.react.dom]
[mranderson047.reagent.v0v6v0.reagent.impl.util :as util] [mranderson047.reagent.v0v7v0.reagent.impl.util :as util]
[mranderson047.reagent.v0v6v0.reagent.impl.template :as tmpl] [mranderson047.reagent.v0v7v0.reagent.impl.template :as tmpl]
[mranderson047.reagent.v0v6v0.reagent.impl.batching :as batch] [mranderson047.reagent.v0v7v0.reagent.impl.batching :as batch]
[mranderson047.reagent.v0v6v0.reagent.ratom :as ratom] [mranderson047.reagent.v0v7v0.reagent.ratom :as ratom]
[mranderson047.reagent.v0v6v0.reagent.debug :refer-macros [dbg]] [mranderson047.reagent.v0v7v0.reagent.debug :refer-macros [dbg]]
[mranderson047.reagent.v0v6v0.reagent.interop :refer-macros [$ $!]])) [mranderson047.reagent.v0v7v0.reagent.interop :refer-macros [$ $!]]))
(defonce ^:private imported nil) (defonce ^:private imported nil)
@ -61,6 +61,8 @@
[this] [this]
($ (module) findDOMNode this)) ($ (module) findDOMNode this))
(set! tmpl/find-dom-node dom-node)
(defn force-update-all (defn force-update-all
"Force re-rendering of all mounted Reagent components. This is "Force re-rendering of all mounted Reagent components. This is
probably only useful in a development environment, when you want to probably only useful in a development environment, when you want to

View File

@ -1,9 +1,9 @@
(ns mranderson047.reagent.v0v6v0.reagent.dom.server (ns mranderson047.reagent.v0v7v0.reagent.dom.server
(:require [cljsjs.react.dom.server] (:require [cljsjs.react.dom.server]
[mranderson047.reagent.v0v6v0.reagent.impl.util :as util] [mranderson047.reagent.v0v7v0.reagent.impl.util :as util]
[mranderson047.reagent.v0v6v0.reagent.impl.template :as tmpl] [mranderson047.reagent.v0v7v0.reagent.impl.template :as tmpl]
[mranderson047.reagent.v0v6v0.reagent.ratom :as ratom] [mranderson047.reagent.v0v7v0.reagent.ratom :as ratom]
[mranderson047.reagent.v0v6v0.reagent.interop :refer-macros [$ $!]])) [mranderson047.reagent.v0v7v0.reagent.interop :refer-macros [$ $!]]))
(defonce ^:private imported nil) (defonce ^:private imported nil)

View File

@ -1,8 +1,8 @@
(ns mranderson047.reagent.v0v6v0.reagent.impl.batching (ns mranderson047.reagent.v0v7v0.reagent.impl.batching
(:refer-clojure :exclude [flush]) (:refer-clojure :exclude [flush])
(:require [mranderson047.reagent.v0v6v0.reagent.debug :refer-macros [dbg]] (:require [mranderson047.reagent.v0v7v0.reagent.debug :refer-macros [dbg assert-some]]
[mranderson047.reagent.v0v6v0.reagent.interop :refer-macros [$ $!]] [mranderson047.reagent.v0v7v0.reagent.interop :refer-macros [$ $!]]
[mranderson047.reagent.v0v6v0.reagent.impl.util :refer [is-client]] [mranderson047.reagent.v0v7v0.reagent.impl.util :refer [is-client]]
[clojure.string :as string])) [clojure.string :as string]))
;;; Update batching ;;; Update batching
@ -45,7 +45,7 @@
(deftype RenderQueue [^:mutable ^boolean scheduled?] (deftype RenderQueue [^:mutable ^boolean scheduled?]
Object Object
(enqueue [this k f] (enqueue [this k f]
(assert (some? f)) (assert-some f "Enqueued function")
(when (nil? (aget this k)) (when (nil? (aget this k))
(aset this k (array))) (aset this k (array)))
(.push (aget this k) f) (.push (aget this k) f)
@ -86,7 +86,7 @@
(run-queue cs)) (run-queue cs))
(.flush-after-render this))) (.flush-after-render this)))
(defonce render-queue (RenderQueue. false)) (defonce render-queue (->RenderQueue false))
(defn flush [] (defn flush []
(.flush-queues render-queue)) (.flush-queues render-queue))

View File

@ -1,9 +1,10 @@
(ns mranderson047.reagent.v0v6v0.reagent.impl.component (ns mranderson047.reagent.v0v7v0.reagent.impl.component
(:require [mranderson047.reagent.v0v6v0.reagent.impl.util :as util] (:require [mranderson047.reagent.v0v7v0.reagent.impl.util :as util]
[mranderson047.reagent.v0v6v0.reagent.impl.batching :as batch] [mranderson047.reagent.v0v7v0.reagent.impl.batching :as batch]
[mranderson047.reagent.v0v6v0.reagent.ratom :as ratom] [mranderson047.reagent.v0v7v0.reagent.ratom :as ratom]
[mranderson047.reagent.v0v6v0.reagent.interop :refer-macros [$ $!]] [mranderson047.reagent.v0v7v0.reagent.interop :refer-macros [$ $!]]
[mranderson047.reagent.v0v6v0.reagent.debug :refer-macros [dbg prn dev? warn error warn-unless]])) [mranderson047.reagent.v0v7v0.reagent.debug :refer-macros [dbg prn dev? warn error warn-unless
assert-callable]]))
(declare ^:dynamic *current-component*) (declare ^:dynamic *current-component*)
@ -85,7 +86,7 @@
(defn wrap-render [c] (defn wrap-render [c]
(let [f ($ c :reagentRender) (let [f ($ c :reagentRender)
_ (assert (ifn? f)) _ (assert-callable f)
res (if (true? ($ c :cljsLegacyRender)) res (if (true? ($ c :cljsLegacyRender))
(.call f c c) (.call f c c)
(let [v (get-argv c) (let [v (get-argv c)
@ -144,7 +145,7 @@
(defn custom-wrapper [key f] (defn custom-wrapper [key f]
(case key (case key
:getDefaultProps :getDefaultProps
(assert false "getDefaultProps not supported") (throw (js/Error. "getDefaultProps not supported"))
:getInitialState :getInitialState
(fn getInitialState [] (fn getInitialState []
@ -201,8 +202,7 @@
(defn get-wrapper [key f name] (defn get-wrapper [key f name]
(let [wrap (custom-wrapper key f)] (let [wrap (custom-wrapper key f)]
(when (and wrap f) (when (and wrap f)
(assert (ifn? f) (assert-callable f))
(str "Expected function in " name key " but got " f)))
(or wrap f))) (or wrap f)))
(def obligatory {:shouldComponentUpdate nil (def obligatory {:shouldComponentUpdate nil
@ -225,8 +225,7 @@
render-fun (-> renders vals first)] render-fun (-> renders vals first)]
(assert (pos? (count renders)) "Missing reagent-render") (assert (pos? (count renders)) "Missing reagent-render")
(assert (== 1 (count renders)) "Too many render functions supplied") (assert (== 1 (count renders)) "Too many render functions supplied")
(assert (ifn? render-fun) (str "Render must be a function, not " (assert-callable render-fun)))
(pr-str render-fun)))))
(let [render-fun (or (:reagentRender fmap) (let [render-fun (or (:reagentRender fmap)
(:componentFunction fmap)) (:componentFunction fmap))
legacy-render (nil? render-fun) legacy-render (nil? render-fun)
@ -264,7 +263,7 @@
{:pre [(map? body)]} {:pre [(map? body)]}
(->> body (->> body
cljsify cljsify
($ util/react createClass))) util/create-class))
(defn component-path [c] (defn component-path [c]
(let [elem (some-> (or (some-> c ($ :_reactInternalInstance)) (let [elem (some-> (or (some-> c ($ :_reactInternalInstance))
@ -291,7 +290,7 @@
"")) ""))
(defn fn-to-class [f] (defn fn-to-class [f]
(assert (ifn? f) (str "Expected a function, not " (pr-str f))) (assert-callable f)
(warn-unless (not (and (react-class? f) (warn-unless (not (and (react-class? f)
(not (reagent-class? f)))) (not (reagent-class? f))))
"Using native React classes directly in Hiccup forms " "Using native React classes directly in Hiccup forms "

View File

@ -1,12 +1,12 @@
(ns mranderson047.reagent.v0v6v0.reagent.impl.template (ns mranderson047.reagent.v0v7v0.reagent.impl.template
(:require [clojure.string :as string] (:require [clojure.string :as string]
[clojure.walk :refer [prewalk]] [clojure.walk :refer [prewalk]]
[mranderson047.reagent.v0v6v0.reagent.impl.util :as util :refer [is-client]] [mranderson047.reagent.v0v7v0.reagent.impl.util :as util :refer [is-client]]
[mranderson047.reagent.v0v6v0.reagent.impl.component :as comp] [mranderson047.reagent.v0v7v0.reagent.impl.component :as comp]
[mranderson047.reagent.v0v6v0.reagent.impl.batching :as batch] [mranderson047.reagent.v0v7v0.reagent.impl.batching :as batch]
[mranderson047.reagent.v0v6v0.reagent.ratom :as ratom] [mranderson047.reagent.v0v7v0.reagent.ratom :as ratom]
[mranderson047.reagent.v0v6v0.reagent.interop :refer-macros [$ $!]] [mranderson047.reagent.v0v7v0.reagent.interop :refer-macros [$ $!]]
[mranderson047.reagent.v0v6v0.reagent.debug :refer-macros [dbg prn println log dev? [mranderson047.reagent.v0v7v0.reagent.debug :refer-macros [dbg prn println log dev?
warn warn-unless]])) warn warn-unless]]))
;; From Weavejester's Hiccup, via pump: ;; From Weavejester's Hiccup, via pump:
@ -98,6 +98,9 @@
;;; Specialization for input components ;;; Specialization for input components
;; This gets set from mranderson047.reagent.v0v7v0.reagent.dom
(defonce find-dom-node nil)
;; <input type="??" > ;; <input type="??" >
;; The properites 'selectionStart' and 'selectionEnd' only exist on some inputs ;; The properites 'selectionStart' and 'selectionEnd' only exist on some inputs
;; See: https://html.spec.whatwg.org/multipage/forms.html#do-not-apply ;; See: https://html.spec.whatwg.org/multipage/forms.html#do-not-apply
@ -109,10 +112,11 @@
(contains? these-inputs-have-selection-api input-type)) (contains? these-inputs-have-selection-api input-type))
(defn input-set-value [this] (defn input-set-value [this]
(when-some [node ($ this :cljsInputElement)] (when ($ this :cljsInputLive)
($! this :cljsInputDirty false) ($! this :cljsInputDirty false)
(let [rendered-value ($ this :cljsRenderedValue) (let [rendered-value ($ this :cljsRenderedValue)
dom-value ($ this :cljsDOMValue)] dom-value ($ this :cljsDOMValue)
node (find-dom-node this)]
(when (not= rendered-value dom-value) (when (not= rendered-value dom-value)
(if-not (and (identical? node ($ js/document :activeElement)) (if-not (and (identical? node ($ js/document :activeElement))
(has-selection-api? ($ node :type)) (has-selection-api? ($ node :type))
@ -172,18 +176,23 @@
(when (and (some? jsprops) (when (and (some? jsprops)
(.hasOwnProperty jsprops "onChange") (.hasOwnProperty jsprops "onChange")
(.hasOwnProperty jsprops "value")) (.hasOwnProperty jsprops "value"))
(assert find-dom-node
"reagent.dom needs to be loaded for controlled input to work")
(let [v ($ jsprops :value) (let [v ($ jsprops :value)
value (if (nil? v) "" v) value (if (nil? v) "" v)
on-change ($ jsprops :onChange)] on-change ($ jsprops :onChange)]
(when (nil? ($ this :cljsInputElement)) (when-not ($ this :cljsInputLive)
;; set initial value ;; set initial value
($! this :cljsInputLive true)
($! this :cljsDOMValue value)) ($! this :cljsDOMValue value))
($! this :cljsRenderedValue value) ($! this :cljsRenderedValue value)
(js-delete jsprops "value") (js-delete jsprops "value")
(doto jsprops (doto jsprops
($! :defaultValue value) ($! :defaultValue value)
($! :onChange #(input-handle-change this on-change %)) ($! :onChange #(input-handle-change this on-change %))))))
($! :ref #($! this :cljsInputElement %1))))))
(defn input-unmount [this]
($! this :cljsInputLive nil))
(defn ^boolean input-component? [x] (defn ^boolean input-component? [x]
(case x (case x
@ -197,6 +206,7 @@
(def input-spec (def input-spec
{:display-name "ReagentInput" {:display-name "ReagentInput"
:component-did-update input-set-value :component-did-update input-set-value
:component-will-unmount input-unmount
:reagent-render :reagent-render
(fn [argv comp jsprops first-child] (fn [argv comp jsprops first-child]
(let [this comp/*current-component*] (let [this comp/*current-component*]
@ -244,7 +254,7 @@
($ util/react createElement c jsprops))) ($ util/react createElement c jsprops)))
(defn adapt-react-class [c] (defn adapt-react-class [c]
(doto (NativeWrapper.) (doto (->NativeWrapper)
($! :name c) ($! :name c)
($! :id nil) ($! :id nil)
($! :class nil))) ($! :class nil)))

View File

@ -1,7 +1,8 @@
(ns mranderson047.reagent.v0v6v0.reagent.impl.util (ns mranderson047.reagent.v0v7v0.reagent.impl.util
(:require [cljsjs.react] (:require [cljsjs.react]
[mranderson047.reagent.v0v6v0.reagent.debug :refer-macros [dbg log warn]] [cljsjs.create-react-class]
[mranderson047.reagent.v0v6v0.reagent.interop :refer-macros [$ $!]] [mranderson047.reagent.v0v7v0.reagent.debug :refer-macros [dbg log warn]]
[mranderson047.reagent.v0v7v0.reagent.interop :refer-macros [$ $!]]
[clojure.string :as string])) [clojure.string :as string]))
(defonce react (defonce react
@ -10,6 +11,12 @@
(throw (js/Error. "require('react') failed"))) (throw (js/Error. "require('react') failed")))
:else (throw (js/Error. "js/React is missing")))) :else (throw (js/Error. "js/React is missing"))))
(defonce create-class
(cond (exists? js/createReactClass) js/createReactClass
(exists? js/require) (or (js/require "create-react-class")
(throw (js/Error. "require('create-react-class') failed")))
:else (throw (js/Error. "js/createReactClass is missing"))))
(def is-client (and (exists? js/window) (def is-client (and (exists? js/window)
(-> js/window ($ :document) nil? not))) (-> js/window ($ :document) nil? not)))
@ -58,17 +65,62 @@
str str
(clojure.string/replace "$" ".")))) (clojure.string/replace "$" "."))))
(deftype partial-ifn [f args ^:mutable p] (deftype PartialFn [pfn f args]
Fn
IFn IFn
(-invoke [_ & a] (-invoke [_]
(or p (set! p (apply clojure.core/partial f args))) (pfn))
(apply p a)) (-invoke [_ a]
(pfn a))
(-invoke [_ a b]
(pfn a b))
(-invoke [_ a b c]
(pfn a b c))
(-invoke [_ a b c d]
(pfn a b c d))
(-invoke [_ a b c d e]
(pfn a b c d e))
(-invoke [_ a b c d e f]
(pfn a b c d e f))
(-invoke [_ a b c d e f g]
(pfn a b c d e f g))
(-invoke [_ a b c d e f g h]
(pfn a b c d e f g h))
(-invoke [_ a b c d e f g h i]
(pfn a b c d e f g h i))
(-invoke [_ a b c d e f g h i j]
(pfn a b c d e f g h i j))
(-invoke [_ a b c d e f g h i j k]
(pfn a b c d e f g h i j k))
(-invoke [_ a b c d e f g h i j k l]
(pfn a b c d e f g h i j k l))
(-invoke [_ a b c d e f g h i j k l m]
(pfn a b c d e f g h i j k l m))
(-invoke [_ a b c d e f g h i j k l m n]
(pfn a b c d e f g h i j k l m n))
(-invoke [_ a b c d e f g h i j k l m n o]
(pfn a b c d e f g h i j k l m n o))
(-invoke [_ a b c d e f g h i j k l m n o p]
(pfn a b c d e f g h i j k l m n o p))
(-invoke [_ a b c d e f g h i j k l m n o p q]
(pfn a b c d e f g h i j k l m n o p q))
(-invoke [_ a b c d e f g h i j k l m n o p q r]
(pfn a b c d e f g h i j k l m n o p q r))
(-invoke [_ a b c d e f g h i j k l m n o p q r s]
(pfn a b c d e f g h i j k l m n o p q r s))
(-invoke [_ a b c d e f g h i j k l m n o p q r s t]
(pfn a b c d e f g h i j k l m n o p q r s t))
(-invoke [_ a b c d e f g h i j k l m n o p q r s t rest]
(apply pfn a b c d e f g h i j k l m n o p q r s t rest))
IEquiv IEquiv
(-equiv [_ other] (-equiv [_ other]
(and (= f (.-f other)) (= args (.-args other)))) (and (= f (.-f other)) (= args (.-args other))))
IHash IHash
(-hash [_] (hash [f args]))) (-hash [_] (hash [f args])))
(defn make-partial-fn [f args]
(->PartialFn (apply partial f args) f args))
(defn- merge-class [p1 p2] (defn- merge-class [p1 p2]
(let [class (when-let [c1 (:class p1)] (let [class (when-let [c1 (:class p1)]
(when-let [c2 (:class p2)] (when-let [c2 (:class p2)]
@ -89,7 +141,8 @@
(if (nil? p1) (if (nil? p1)
p2 p2
(do (do
(assert (map? p1)) (assert (map? p1)
(str "Property must be a map, not " (pr-str p1)))
(merge-style p1 (merge-class p1 (merge p1 p2)))))) (merge-style p1 (merge-class p1 (merge p1 p2))))))

View File

@ -1,6 +1,5 @@
(ns mranderson047.reagent.v0v6v0.reagent.interop (ns mranderson047.reagent.v0v7v0.reagent.interop
(:require [clojure.string :as string :refer [join]] (:require [clojure.string :as string :refer [join]]))
[clojure.java.io :as io]))
(defn- js-call [f args] (defn- js-call [f args]
(let [argstr (->> (repeat (count args) "~{}") (let [argstr (->> (repeat (count args) "~{}")
@ -10,7 +9,7 @@
(defn- dot-args [object member] (defn- dot-args [object member]
(assert (or (symbol? member) (assert (or (symbol? member)
(keyword? member)) (keyword? member))
(str "Symbol or keyword expected, not " member)) (str "Symbol or keyword expected, not " (pr-str member)))
(assert (or (not (symbol? object)) (assert (or (not (symbol? object))
(not (re-find #"\." (name object)))) (not (re-find #"\." (name object))))
(str "Dot not allowed in " object)) (str "Dot not allowed in " object))
@ -55,21 +54,3 @@
(let [[field names] (dot-args object field)] (let [[field names] (dot-args object field)]
(assert field (str "Field name must start with - in " field)) (assert field (str "Field name must start with - in " field))
`(aset ~object ~@names ~value))) `(aset ~object ~@names ~value)))
(defmacro .' [& args]
;; Deprecated since names starting with . cause problems with bootstrapped cljs.
(let [ns (str cljs.analyzer/*cljs-ns*)
line (:line (meta &form))]
(binding [*out* *err*]
(println "WARNING: mranderson047.reagent.v0v6v0.reagent.interop/.' is deprecated in " ns " line " line
". Use mranderson047.reagent.v0v6v0.reagent.interop/$ instead.")))
`($ ~@args))
(defmacro .! [& args]
;; Deprecated since names starting with . cause problems with bootstrapped cljs.
(let [ns (str cljs.analyzer/*cljs-ns*)
line (:line (meta &form))]
(binding [*out* *err*]
(println "WARNING: mranderson047.reagent.v0v6v0.reagent.interop/.! is deprecated in " ns " line " line
". Use mranderson047.reagent.v0v6v0.reagent.interop/$! instead.")))
`($! ~@args))

View File

@ -0,0 +1,2 @@
(ns mranderson047.reagent.v0v7v0.reagent.interop
(:require-macros [mranderson047.reagent.v0v7v0.reagent.interop]))

View File

@ -1,21 +1,23 @@
(ns mranderson047.reagent.v0v6v0.reagent.ratom (ns mranderson047.reagent.v0v7v0.reagent.ratom
(:refer-clojure :exclude [run!]) (:refer-clojure :exclude [run!])
(:require [mranderson047.reagent.v0v6v0.reagent.debug :as d])) (:require [mranderson047.reagent.v0v7v0.reagent.debug :as d]))
(defmacro reaction [& body] (defmacro reaction [& body]
`(mranderson047.reagent.v0v6v0.reagent.ratom/make-reaction `(mranderson047.reagent.v0v7v0.reagent.ratom/make-reaction
(fn [] ~@body))) (fn [] ~@body)))
(defmacro run! (defmacro run!
"Runs body immediately, and runs again whenever atoms deferenced in the body change. Body should side effect." "Runs body immediately, and runs again whenever atoms deferenced in the body change. Body should side effect."
[& body] [& body]
`(let [co# (mranderson047.reagent.v0v6v0.reagent.ratom/make-reaction (fn [] ~@body) `(let [co# (mranderson047.reagent.v0v7v0.reagent.ratom/make-reaction (fn [] ~@body)
:auto-run true)] :auto-run true)]
(deref co#) (deref co#)
co#)) co#))
(defmacro with-let [bindings & body] (defmacro with-let [bindings & body]
(assert (vector? bindings)) (assert (vector? bindings)
(str "with-let bindings must be a vector, not "
(pr-str bindings)))
(let [v (gensym "with-let") (let [v (gensym "with-let")
k (keyword v) k (keyword v)
init (gensym "init") init (gensym "init")
@ -35,14 +37,14 @@
[body nil])) [body nil]))
add-destroy (when destroy add-destroy (when destroy
`(let [destroy# ~destroy] `(let [destroy# ~destroy]
(if (mranderson047.reagent.v0v6v0.reagent.ratom/reactive?) (if (mranderson047.reagent.v0v7v0.reagent.ratom/reactive?)
(when (nil? (.-destroy ~v)) (when (nil? (.-destroy ~v))
(set! (.-destroy ~v) destroy#)) (set! (.-destroy ~v) destroy#))
(destroy#)))) (destroy#))))
asserting (if *assert* true false)] asserting (if *assert* true false)]
`(let [~v (mranderson047.reagent.v0v6v0.reagent.ratom/with-let-values ~k)] `(let [~v (mranderson047.reagent.v0v7v0.reagent.ratom/with-let-values ~k)]
(when ~asserting (when ~asserting
(when-some [c# mranderson047.reagent.v0v6v0.reagent.ratom/*ratom-context*] (when-some [c# mranderson047.reagent.v0v7v0.reagent.ratom/*ratom-context*]
(when (== (.-generation ~v) (.-ratomGeneration c#)) (when (== (.-generation ~v) (.-ratomGeneration c#))
(d/error "Warning: The same with-let is being used more " (d/error "Warning: The same with-let is being used more "
"than once in the same reactive context.")) "than once in the same reactive context."))

View File

@ -1,9 +1,9 @@
(ns mranderson047.reagent.v0v6v0.reagent.ratom (ns mranderson047.reagent.v0v7v0.reagent.ratom
(:refer-clojure :exclude [atom]) (:refer-clojure :exclude [atom])
(:require-macros [mranderson047.reagent.v0v6v0.reagent.ratom :refer [with-let]]) (:require-macros [mranderson047.reagent.v0v7v0.reagent.ratom :refer [with-let]])
(:require [mranderson047.reagent.v0v6v0.reagent.impl.util :as util] (:require [mranderson047.reagent.v0v7v0.reagent.impl.util :as util]
[mranderson047.reagent.v0v6v0.reagent.debug :refer-macros [dbg log warn error dev? time]] [mranderson047.reagent.v0v7v0.reagent.debug :refer-macros [dbg log warn error dev? time]]
[mranderson047.reagent.v0v6v0.reagent.impl.batching :as batch] [mranderson047.reagent.v0v7v0.reagent.impl.batching :as batch]
[clojure.set :as s])) [clojure.set :as s]))
(declare ^:dynamic *ratom-context*) (declare ^:dynamic *ratom-context*)
@ -162,8 +162,8 @@
(defn atom (defn atom
"Like clojure.core/atom, except that it keeps track of derefs." "Like clojure.core/atom, except that it keeps track of derefs."
([x] (RAtom. x nil nil nil)) ([x] (->RAtom x nil nil nil))
([x & {:keys [meta validator]}] (RAtom. x meta validator nil))) ([x & {:keys [meta validator]}] (->RAtom x meta validator nil)))
;;; track ;;; track
@ -306,7 +306,7 @@
(not (vector? src)))) (not (vector? src))))
(str "src must be a reactive atom or a function, not " (str "src must be a reactive atom or a function, not "
(pr-str src))) (pr-str src)))
(RCursor. src path nil nil nil)) (->RCursor src path nil nil nil))
;;; with-let support ;;; with-let support
@ -354,7 +354,7 @@
IReset IReset
(-reset! [a newval] (-reset! [a newval]
(assert (fn? (.-on-set a)) "Reaction is read only.") (assert (fn? (.-on-set a)) "Reaction is read only; on-set is not allowed")
(let [oldval state] (let [oldval state]
(set! state newval) (set! state newval)
(.on-set a oldval newval) (.on-set a oldval newval)
@ -486,7 +486,7 @@
(defn make-reaction [f & {:keys [auto-run on-set on-dispose]}] (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 (._set-opts reaction {:auto-run auto-run
:on-set on-set :on-set on-set
:on-dispose on-dispose}) :on-dispose on-dispose})
@ -563,9 +563,9 @@
(-pr-writer [a w opts] (pr-atom a w opts "Wrap:"))) (-pr-writer [a w opts] (pr-atom a w opts "Wrap:")))
(defn make-wrapper [value callback-fn args] (defn make-wrapper [value callback-fn args]
(Wrapper. value (->Wrapper value
(util/partial-ifn. callback-fn args nil) (util/make-partial-fn callback-fn args)
false nil)) false nil))