This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (2)
- # aws (4)
- # babashka (14)
- # beginners (186)
- # cljdoc (2)
- # cljsrn (7)
- # clojure (56)
- # clojure-austin (1)
- # clojure-australia (2)
- # clojure-europe (46)
- # clojure-france (5)
- # clojure-nl (16)
- # clojure-norway (7)
- # clojure-spec (76)
- # clojure-sweden (15)
- # clojure-uk (13)
- # clojurescript (60)
- # code-reviews (2)
- # conjure (8)
- # datascript (1)
- # datomic (4)
- # depstar (10)
- # emacs (9)
- # events (4)
- # exercism (1)
- # fulcro (36)
- # graalvm (8)
- # introduce-yourself (3)
- # jobs-discuss (2)
- # kaocha (14)
- # lsp (1)
- # minecraft (8)
- # new-channels (1)
- # off-topic (3)
- # pathom (6)
- # polylith (9)
- # re-frame (48)
- # shadow-cljs (5)
- # specter (26)
- # tools-deps (19)
- # vim (2)
- # vscode (1)
I have this event reg
(rf/reg-event-db ::toggle-starred (fn-traced [db [_ person-id]] (let [val (get-in db [:tracker :person-list :people person-id :starred]) x (util/console-log val)] (assoc-in db [:tracker :person-list :people person-id :starred] (not val)) )))
if I remove the last key just to see what the get-in is returning, its just the starred property even if I never specify it -_-
To weed out the obvious thing - are you 100% sure
person-id is always the same one and is always correct?
Do you have any global interceptors registered?
Also, just in case - no need for
assoc-in when you have
(update-in db [...] not)
Question: any particular reason it’s not
(rf/reg-event-db ::toggle-starred (fn-traced [db [_ person-id]] (update-in db [:tracker :person-list :people person-id :starred] not)))
No reason in particular! 🙂 I started with that and broke it out to try and see what was failing but let me try it again that way
If you're sure about
person-id and you're sure about there not being any global interceptors that might influence that value, then I'd try to come up with a minimal reproducible example. Otherwise, it's just crystal gazing.
Right, so now the event itself is not throwing any console errors, but the app-db inspector does not show the value updating
(ns pnx-web.events (:require [re-frame.core :as rf] [re-pressed.core :as rp] [pnx-web.db :as db] [day8.re-frame.tracing :refer-macros [fn-traced]] [pnx-web.util.core :as util]))
If it's a small public project available somewhere along with instructions or an obvious way to run it, I can take a look.
It is none of those things, unfortunately. 😕 It appears the db is not getting updated and nothing is obviously erroring, Am getting some warnings about seqs not having keys, but I don't think that would manifest this way
The part that gets me about this is you saying the first time you run it it’s still null
I think one of the items in the db. is in an extra vector I didn't mean for it to be in and that's confounding some things
my people list is a vector of maps that are keyed by the id.. trying to use the indexed entity pattern
My hubris leads me to believe the problem is always more complicated than it ends up being! Learning clj is a humbling experience for sure, haha!
Clojure has different print statements.
print and println produce output for human consumption.
I learned early on not to use that ^^^, for this very reason. Better:
"The reader" means the Clojure reader. This is the one that will print strings showing the quotation marks.
By default, pr and prn print in a way that objects can be read by the reader
And FWIW, when in the browser, I always use
1 will be printed slightly differently, enough for me to notice, but there will be a benefit of being able to interactively study the printed objects, both CLJS and JS ones.