Skip to content

Commit

Permalink
[refactor] Consolidate db/path semantics
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kimo-k committed Jul 16, 2023
1 parent fd1b12a commit 31aacbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/releases/2023.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 4 additions & 4 deletions src/re_frame/std_interceptors.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 31aacbc

Please sign in to comment.