This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-28
Channels
- # 100-days-of-code (10)
- # announcements (2)
- # architecture (16)
- # beginners (51)
- # bitcoin (3)
- # calva (1)
- # cider (6)
- # cljdoc (8)
- # cljs-dev (14)
- # cljsrn (4)
- # clojure (59)
- # clojure-italy (26)
- # clojure-losangeles (1)
- # clojure-nl (13)
- # clojure-spec (54)
- # clojure-uk (81)
- # clojurebridge (4)
- # clojurescript (20)
- # core-async (16)
- # cursive (39)
- # datomic (27)
- # emacs (12)
- # events (1)
- # figwheel-main (20)
- # fulcro (35)
- # funcool (1)
- # graphql (9)
- # hyperfiddle (10)
- # jobs (1)
- # jobs-discuss (7)
- # keechma (10)
- # lumo (22)
- # nrepl (18)
- # off-topic (28)
- # onyx (3)
- # pedestal (4)
- # re-frame (8)
- # reagent (8)
- # ring (4)
- # rum (3)
- # shadow-cljs (29)
- # testing (5)
when you break down a component do you pass in parameters to the subcomponent or do you have the subcomponent dereference the subscriptions?
I’ve ended up doing both as well. In my head I call pure components components
and ones that subscribe to db I call views
. In this parlance views
are composed from components
and subscriptions.
Usually I refactor view into a component when I notice that I need the same stuff in some other place.
In my utils namespace there is a distinct-by
function, a custom version of distinct
that applys a f
in the values
https://gist.github.com/souenzzo/2a2e74d56fc7bd6e7a35977bfb0939b9
It do the same of distinct
Or you can do (def distinct-by #(map (comp first val) (group-by %1 %2)))
Can someone give me some feedback on how this could be cleaned up?
(def credentials (r/atom nil))
(def client (ratom/reaction
(when @credentials
(create-client @credentials))))
(def data (let [a (r/atom nil)
b (ratom/reaction
(when @client
(.then (.query @client)
#(reset! a %))))]
@b
(ratom/make-reaction
(fn [] @a)
:on-dispose #(ratom/dispose! b))))
I have credentials that have to be requested from the server via an API. Once I have those, I can create a client. Once I have that client, I need to make queries which return promises. The problem is, I can't find a clean way to get the response from those promises into a reaction.
FYI, I'm using this in a re-frame handler, though I've removed re-frame specific stuff for this question.