Fork me on GitHub
#re-frame
<
2016-12-28
>
manishkumarmdb09:12:15

👍 @mikethompson

rafaelzlisboa11:12:54

let me get your thoughts on something: have you ever felt the need for a naming standard for atoms? 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

rafaelzlisboa11:12:39

(guess the question is… does that make sense to anybody else, or is that a smell that we're doing something wrong)

pbaille16:12:09

@rafaelzlisboa I use this convention to, and find it useful

pbaille16:12:26

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?

pbaille16:12:27

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.

pbaille16:12:35

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.

pbaille16:12:42

Also, i'm wondering if the idea of 'sub-frame' make sense to anybody?

pbaille16:12:42

for my cursor related question am I supposed to do something like this?

(rf/reg-sub
  :cursor
  (fn [db [_ path]]
    (r/cursor db path)))

pbaille16:12:49

something like this maybe?

(defn db-cursor [path]
  (reagent.core/cursor re-frame.db/app-db path))

geoffs17:12:56

@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.

geoffs17:12:14

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

pbaille19:12:19

@geoffs thank you, it makes sense

mikethompson20:12:34

@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)

mikethompson20:12:36

This data is what identifies the "instance"

geoffs20:12:19

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 😆