This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-17
Channels
- # announcements (6)
- # babashka (2)
- # babashka-sci-dev (1)
- # beginners (74)
- # calva (3)
- # cider (33)
- # clj-kondo (19)
- # cljsrn (10)
- # clojure (75)
- # clojure-dev (11)
- # clojure-europe (39)
- # clojure-italy (1)
- # clojure-nl (1)
- # clojure-spec (4)
- # clojure-uk (6)
- # clojurescript (139)
- # code-reviews (8)
- # core-typed (7)
- # data-science (1)
- # docs (2)
- # emacs (11)
- # events (1)
- # introduce-yourself (8)
- # lsp (4)
- # malli (10)
- # off-topic (15)
- # pedestal (5)
- # podcasts-discuss (4)
- # polylith (18)
- # re-frame (6)
- # react (1)
- # reagent (18)
- # reitit (6)
- # releases (2)
- # rewrite-clj (1)
- # spacemacs (15)
- # sql (2)
- # vscode (5)
Is there any rule against adding effects in an interceptor's :before
handler? By the time :after
runs, I don't see the effect there.
reg-event-db
adds effect :db
to the :effects
map in the context.
reg-event-fx
replaces the whole :effects
map in the context - perhaps you're seeing this.
reg-event-ctx
replace the whole context - so could also be this.
I see, thanks. That seems to rule out my use case.
Hoping to design an interceptor that loads data from a cache (coeffect) if available, and dispatches a request (effect) if it's not. I'm just not sure how to use a such a predicate from :before
in the :after
handler.
Given how the aforementioned event registering functions work, you can't do it reliably in a :before
interceptor because your effects might get overwritten.
But why do you need :before
? Why not just use :after
for everything?
I was thinking the effect might need the data as a coeffect if it was available. Maybe not, though.
Coeffects don't disappear after the event handler is run. Unless you used reg-event-ctx
, which, as I mentioned, can replace the whole context along with the coeffects. But same is true for any other interceptor - e.g. you can't really use path
with reg-event-ctx
if you replace the whole context in the latter.
So if you don't use reg-event-ctx
or update the context and not just replace it, all should be good.