Tweak trim-v patch
- Add another test assertion - Add changelog - Tweak style of std interceptor to use dissoc-in
This commit is contained in:
parent
ff7c175de0
commit
bd18563f5d
|
@ -16,6 +16,7 @@
|
|||
- Added `clear-subscription-cache!` function. This should be used when hot reloading code to ensure that any bad subscriptions that cause rendering exceptions are removed. See [reagent-project/reagent#272](https://github.com/reagent-project/reagent/issues/272) for more details.
|
||||
- Added experimental tracing features. These are subject to change and remain undocumented at the moment. By default they are disabled, and will be completely compiled out by advanced optimisations. To enable them, set a [`:closure-defines`](https://www.martinklepsch.org/posts/parameterizing-clojurescript-builds.html) key to `{"re_frame.trace.trace_enabled_QMARK_" true}`
|
||||
- [#223](https://github.com/Day8/re-frame/issues/223) When using `make-restore-fn`, dispose of any subscriptions that were created after the restore function was created.
|
||||
- [#283](https://github.com/Day8/re-frame/pull/283) Make trim-v interceptor symmetrical, so it adds the missing event id back on to the `:event` coeffect in the `:after` function.
|
||||
|
||||
#### Fixes
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
[re-frame.registrar :as registrar]
|
||||
[re-frame.db :refer [app-db]]
|
||||
[clojure.data :as data]
|
||||
[re-frame.cofx :as cofx]))
|
||||
[re-frame.cofx :as cofx]
|
||||
[re-frame.utils :as utils]))
|
||||
|
||||
|
||||
;; XXX provide a way to set what handler should be called when there is no registered handler.
|
||||
|
@ -69,8 +70,8 @@
|
|||
:after (fn trimv-after
|
||||
[context]
|
||||
(-> context
|
||||
(assoc-in [:coeffects :event] (get-coeffect context ::untrimmed-event))
|
||||
(update :coeffects dissoc ::untrimmed-event)))))
|
||||
(utils/dissoc-in [:coeffects ::untrimmed-event])
|
||||
(assoc-in [:coeffects :event] (get-coeffect context ::untrimmed-event))))))
|
||||
|
||||
|
||||
;; -- Interceptor Factories - PART 1 ---------------------------------------------------------------
|
||||
|
|
|
@ -3,6 +3,20 @@
|
|||
[re-frame.loggers :refer [console]]
|
||||
[reagent.ratom :as ratom]))
|
||||
|
||||
(defn dissoc-in
|
||||
"Dissociates an entry from a nested associative structure returning a new
|
||||
nested structure. keys is a sequence of keys. Any empty maps that result
|
||||
will not be present in the new structure.
|
||||
The key thing is that 'm' remains identical? to istelf if the path was never present"
|
||||
[m [k & ks :as keys]]
|
||||
(if ks
|
||||
(if-let [nextmap (get m k)]
|
||||
(let [newmap (dissoc-in nextmap ks)]
|
||||
(if (seq newmap)
|
||||
(assoc m k newmap)
|
||||
(dissoc m k)))
|
||||
m)
|
||||
(dissoc m k)))
|
||||
|
||||
(defn first-in-vector
|
||||
[v]
|
||||
|
|
|
@ -9,13 +9,14 @@
|
|||
(enable-console-print!)
|
||||
|
||||
(deftest test-trim-v
|
||||
(let [ctx (context [:a :b :c] [])
|
||||
c ((:before trim-v) ctx)]
|
||||
(is (= (get-coeffect c :event)
|
||||
(let [ctx (context [:event-id :b :c] [])
|
||||
ctx-trimmed ((:before trim-v) ctx)
|
||||
ctx-untrimmed ((:after trim-v) ctx-trimmed)]
|
||||
(is (= (get-coeffect ctx-trimmed :event)
|
||||
[:b :c]))
|
||||
|
||||
(let [c-after ((:after trim-v) c)]
|
||||
(is (= c-after ctx)))))
|
||||
(is (= (get-coeffect ctx-untrimmed :event)
|
||||
[:event-id :b :c]))
|
||||
(is (= ctx-untrimmed ctx))))
|
||||
|
||||
|
||||
(deftest test-one-level-path
|
||||
|
|
Loading…
Reference in New Issue