Fork me on GitHub

👍 @mikethompson


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


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


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


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

  (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 thank you, it makes sense


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