This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-28
Channels
- # ai (1)
- # beginners (190)
- # boot (24)
- # cider (43)
- # cljsjs (3)
- # cljsrn (29)
- # clojars (6)
- # clojure (310)
- # clojure-dev (6)
- # clojure-nl (6)
- # clojure-russia (11)
- # clojure-spec (66)
- # clojure-uk (95)
- # clojurescript (103)
- # clojurewerkz (2)
- # core-async (9)
- # cursive (4)
- # datomic (5)
- # hoplon (163)
- # lein-figwheel (52)
- # off-topic (6)
- # om (6)
- # onyx (42)
- # perun (8)
- # re-frame (16)
- # reagent (10)
- # ring (7)
- # ring-swagger (1)
- # rum (1)
- # slack-help (2)
- # uncomplicate (1)
- # untangled (80)
let me get your thoughts on something:
have you ever felt the need for a naming standard for atom
s? in the codebase i work at, we’ve started to declare the result of subscriptions as something*
instead of something
, and it helps us know when a value needs to be deref’ed or not
(guess the question is… does that make sense to anybody else, or is that a smell that we're doing something wrong)
@rafaelzlisboa I use this convention to, and find it useful
I'm porting a big project from reagent to re-frame and i'm struggling with something: many of my reagent component use cursors built from a global atom. Is there a good way to make cursor from the re-frame app-db?
I kind of see the dirty way to implement it with watchers but I would prefer to have your thoughts on this before doing wrong things.
also i'm wondering what is the good practice concerning the decoupling of components from the re-frame system. Many of my components have to be usable as standalone components as well as embedded components in the re-frame app.
for my cursor related question am I supposed to do something like this?
(rf/reg-sub
:cursor
(fn [db [_ path]]
(r/cursor db path)))
something like this maybe?
(defn db-cursor [path]
(reagent.core/cursor re-frame.db/app-db path))
@pbaille For decoupling components from re-frame, just make sure they don't call any re-frame specific code (like dispatch
or subscribe
) directly inside the component. Instead, if they need to hook into that behavior pass the function call or the data from the subscription in to the component via parameters. Then write a super-thin re-frame specific wrapper component to instantiate the pure reagent component with the correct parameters.
I actually always prefer to write my components in this style, I think it's simply a lot cleaner in general. Writing your components outside the re-frame app (inside a devcard for instance) can really help with making sure that all the dependencies are explicitly passed in
@geoffs @pbaille OR you pass into the component some data (a path?, an id) which it then includes in any internal subscribes and dispatches (in the query vector or event vector)
This data is what identifies the "instance"
I haven't played with doing it that way @mikethompson. But I've only written very small toy re-frame apps and my subscriptions and dispatches are almost always one-offs 😆