This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-10
Channels
- # 100-days-of-code (2)
- # announcements (2)
- # aws (11)
- # beginners (114)
- # boot (6)
- # calva (11)
- # cider (11)
- # cljdoc (2)
- # cljs-dev (7)
- # clojure (126)
- # clojure-berlin (1)
- # clojure-conj (4)
- # clojure-dev (1)
- # clojure-germany (12)
- # clojure-italy (22)
- # clojure-spec (96)
- # clojure-uk (111)
- # clojurescript (27)
- # core-async (8)
- # cursive (17)
- # datomic (26)
- # devops (5)
- # editors (15)
- # emacs (13)
- # events (1)
- # figwheel-main (27)
- # fulcro (64)
- # hyperfiddle (29)
- # jobs (8)
- # jobs-discuss (7)
- # liberator (4)
- # off-topic (46)
- # om (9)
- # onyx (1)
- # overtone (1)
- # perun (8)
- # re-frame (28)
- # reagent (35)
- # reitit (5)
- # shadow-cljs (96)
- # spacemacs (1)
- # testing (10)
- # timbre (8)
- # tools-deps (63)
- # unrepl (1)
- # yada (10)
(def ^:private reorder-after-interceptor (re-frame/after (partial order-questions)))
Can I register a default subscription? Getting tired of retrieving simple keys from the root of the app-db.
i use a macro to do some fancy footwork with exposing a rest-style entity interface with a set of default reg-event-db and reg-subs for get/post/put/delete etc.
I guess it makes it hard to detect when a particular part of state is updated, and tie it to a component.
@danielstockton not sure what you mean by default, but I’ve got a dead simple subscription for stuff like that, that is ostensibly “what key in a specific path in the db do I want to fetch”
@samueldev That's what I'm looking for, but I only see how to register subscriptions using a particular key.
If you have one subscription doing that, then that's what I'm looking for really
@danielstockton You can give subscriptions arguments, so it wouldn't be too technically difficult to implement such a thing... but you'd lose all the benefits of subscription cacheing, which is why iirc the docs discourage this approach. Still could be reasonable to do it while prototyping.
(re-frame/reg-sub
::default
(fn [db [_ k]
(k db)))
yeah, the last heading on https://github.com/Day8/re-frame/blob/master/docs/SubscriptionsCleanup.md covers this idea
Thanks @andrew354, thought it might come with some downsides.
Yeah, still have to explicitly name all the keys though. Nevermind, it's a bit tedious, but at least it's simple.
so when I'm having an event handler that looks like (fn handler [fx _] (-> (assoc-in fx [:db :foo] :bar) (assoc :dispatch [:not-important])))
I'm getting "no handler registered for effect event
"
i thought writing the handlers like them would make them more flexible, but it seems that it's not intended
because fx has information about the current event and just passing it on causes the above error
Interesting pattern to pass on the fx
with some changes @arne-clojurians. I've generally been destructuring in the arg vector for just the db and returning a map literal.
(fn handler [{db :db} _] {:db (-> db (assoc ...
But your approach might be useful in certain situtations: is there more than just the db you'd like to pass through?