This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-25
Channels
- # babashka (77)
- # beginners (107)
- # calva (20)
- # cider (2)
- # clj-kondo (7)
- # clojure (63)
- # clojure-australia (2)
- # clojure-europe (75)
- # clojure-germany (10)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-serbia (15)
- # clojure-spain (2)
- # clojure-uk (24)
- # clojurescript (54)
- # clojureverse-ops (3)
- # cursive (20)
- # datahike (4)
- # datalog (5)
- # datascript (8)
- # datomic (13)
- # emacs (2)
- # fulcro (1)
- # graalvm (2)
- # instaparse (1)
- # jobs (2)
- # luminus (1)
- # malli (7)
- # off-topic (28)
- # pathom (6)
- # pedestal (2)
- # re-frame (5)
- # reagent (9)
- # remote-jobs (4)
- # rewrite-clj (4)
- # ring (19)
- # shadow-cljs (2)
- # spacemacs (2)
- # sql (10)
- # tools-deps (6)
- # xtdb (12)
(def db {:form {:entity-id 1}
...})
(reg-sub
::get-some-entity
:<- [:a lot]
:<- [:of]
:<- [:signals]
(fn [[yada yada yada] [_ entity-id]]
(some (really (complicated code))))
(reg-sub
::get-entity-from-form
(fn [db [_ form-path]]
???????)
(defn my-form []
(let [form-path :form
entity @(re-frame/subscrible [::get-entity-from-form form-path])]
[render-entity entity]))
I have some really complicated subscription with a lot of input signals, which extracts some entity
from the db which I can’t replicate as a function of db. Also I have a form stored in the db, which has that entity
id inside it. I want a subscription which given a form path gives me back entity
(marked with ???????
in the code above).
So, essentially what I want to do :
1. given path to form extract :entity-id
2. use that :entity-id
as an input to ::get-some-entity
and I want to do all of that inside subscriptions, without passing data through the form rendering.
Is that possible in re-frame?I'm pretty sure you can safely use @(subscribe ...)
within the reg-sub
handler.
Alternatively, use reg-sub-raw
.
Is there a way to check if a subscription is already registered given a query-id?
I figure I could use the re-frame.registrar
namespace functionality, but that feels like relying on internal api too much