From 31aacbc8ff0c19fcb1d538da389a9a8dae0157cf Mon Sep 17 00:00:00 2001 From: Kimo Knowles Date: Mon, 26 Jun 2023 13:51:28 +0200 Subject: [PATCH] [refactor] Consolidate db/path semantics From one point of view, a namespace adds essential context to the name. E.g., not just a path, but a path in terms of re-frame's app-db. Arguably, the :re-frame.db concern doesn't depend on the present concept of "store" or "history", but neither does :re-frame-path. Since this is the only mention of :re-frame-path, I think :re-frame.db is a more conventional point of context. --- docs/releases/2023.md | 4 ++-- src/re_frame/std_interceptors.cljc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/releases/2023.md b/docs/releases/2023.md index 85c0527d1..da5cb0461 100644 --- a/docs/releases/2023.md +++ b/docs/releases/2023.md @@ -10,6 +10,6 @@ > Committed but unreleased changes are put here, at the top. Older releases are detailed chronologically below. -#### Breaking - +#### Breaking + - `re-frame.std-interceptors/path` now keeps a `:re-frame.db/path-history` key in the context, not a `:re-frame-path/db-store` key. This shouldn't affect users, unless you're directly hacking the event loop. - [763](https://github.com/day8/re-frame/pull/763) on detecting an incorrect event structure, the `unwrap` interceptor now exceptions instead of writing an error to `js/console` and continuing. diff --git a/src/re_frame/std_interceptors.cljc b/src/re_frame/std_interceptors.cljc index 1897dd4cf..da943332c 100644 --- a/src/re_frame/std_interceptors.cljc +++ b/src/re_frame/std_interceptors.cljc @@ -166,7 +166,7 @@ (defn path [& args] (let [path (flatten args) - db-store-key :re-frame-path/db-store] ;; this is where, within `context`, we store the original dbs + history-key :re-frame.db/path-history] ;; this is where, within `context`, we store the original dbs (when (empty? path) (console :error "re-frame: \"path\" interceptor given no params")) (->interceptor @@ -175,13 +175,13 @@ [context] (let [original-db (get-coeffect context :db)] (-> context - (update db-store-key conj original-db) + (update history-key conj original-db) (assoc-coeffect :db (get-in original-db path))))) :after (fn [context] - (let [db-store (db-store-key context) + (let [db-store (history-key context) original-db (peek db-store) new-db-store (pop db-store) - context' (-> (assoc context db-store-key new-db-store) + context' (-> (assoc context history-key new-db-store) (assoc-coeffect :db original-db)) ;; put the original db back so that things like debug work later on db (get-effect context :db ::not-found)] (if (= db ::not-found)