mirror of
https://github.com/status-im/re-frame.git
synced 2025-02-23 07:18:22 +00:00
Move reagent-id fn to re-frame.interop
This commit is contained in:
parent
5364a83aee
commit
b53062e859
@ -76,3 +76,8 @@
|
|||||||
;; currentTimeMillis may count backwards in some scenarios, but as this is used for tracing
|
;; currentTimeMillis may count backwards in some scenarios, but as this is used for tracing
|
||||||
;; it is preferable to the slower but more accurate System.nanoTime.
|
;; it is preferable to the slower but more accurate System.nanoTime.
|
||||||
(System/currentTimeMillis))
|
(System/currentTimeMillis))
|
||||||
|
|
||||||
|
(defn reagent-id
|
||||||
|
"Doesn't make sense in a Clojure context currently."
|
||||||
|
[reactive-val]
|
||||||
|
nil)
|
||||||
|
@ -41,3 +41,16 @@
|
|||||||
(if (exists? js/performance.now)
|
(if (exists? js/performance.now)
|
||||||
(js/performance.now)
|
(js/performance.now)
|
||||||
(js/Date.now)))
|
(js/Date.now)))
|
||||||
|
|
||||||
|
(defn reagent-id
|
||||||
|
"Produces an id for reactive Reagent values
|
||||||
|
e.g. reactions, ratoms, cursors."
|
||||||
|
[reactive-val]
|
||||||
|
(when (implements? reagent.ratom/IReactiveAtom reactive-val)
|
||||||
|
(str (condp instance? reactive-val
|
||||||
|
reagent.ratom/RAtom "ra"
|
||||||
|
reagent.ratom/RCursor "rc"
|
||||||
|
reagent.ratom/Reaction "rx"
|
||||||
|
reagent.ratom/Track "tr"
|
||||||
|
"other")
|
||||||
|
(hash reactive-val))))
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
(ns re-frame.subs
|
(ns re-frame.subs
|
||||||
(:require
|
(:require
|
||||||
[re-frame.db :refer [app-db]]
|
[re-frame.db :refer [app-db]]
|
||||||
[re-frame.interop :refer [add-on-dispose! debug-enabled? make-reaction ratom? deref? dispose!]]
|
[re-frame.interop :refer [add-on-dispose! debug-enabled? make-reaction ratom? deref? dispose! reagent-id]]
|
||||||
[re-frame.loggers :refer [console]]
|
[re-frame.loggers :refer [console]]
|
||||||
[re-frame.utils :refer [first-in-vector reagent-id]]
|
[re-frame.utils :refer [first-in-vector]]
|
||||||
[re-frame.registrar :refer [get-handler clear-handlers register-handler]]
|
[re-frame.registrar :refer [get-handler clear-handlers register-handler]]
|
||||||
[re-frame.trace :as trace :include-macros true]))
|
[re-frame.trace :as trace :include-macros true]))
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
(ns re-frame.utils
|
(ns re-frame.utils
|
||||||
(:require
|
(:require
|
||||||
[re-frame.loggers :refer [console]]
|
[re-frame.loggers :refer [console]]))
|
||||||
#?(:cljs [reagent.ratom :as ratom])))
|
|
||||||
|
|
||||||
(defn dissoc-in
|
(defn dissoc-in
|
||||||
"Dissociates an entry from a nested associative structure returning a new
|
"Dissociates an entry from a nested associative structure returning a new
|
||||||
@ -23,16 +22,3 @@
|
|||||||
(if (vector? v)
|
(if (vector? v)
|
||||||
(first v)
|
(first v)
|
||||||
(console :error "re-frame: expected a vector, but got:" v)))
|
(console :error "re-frame: expected a vector, but got:" v)))
|
||||||
|
|
||||||
(defn reagent-id
|
|
||||||
"Produces an id for reactive Reagent values
|
|
||||||
e.g. reactions, ratoms, cursors."
|
|
||||||
[reactive-val]
|
|
||||||
#?(:cljs (when (implements? ratom/IReactiveAtom reactive-val)
|
|
||||||
(str (condp instance? reactive-val
|
|
||||||
ratom/RAtom "ra"
|
|
||||||
ratom/RCursor "rc"
|
|
||||||
ratom/Reaction "rx"
|
|
||||||
ratom/Track "tr"
|
|
||||||
"other")
|
|
||||||
(hash reactive-val)))))
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user