Fork me on GitHub
Braden Shepherdson20:01:03

is there any kind of... canned controllers for re-frame?

Braden Shepherdson20:01:20

I mean, things bigger than "components", things like a master-detail flow, or a table with slice-n-dice filtering.

Braden Shepherdson20:01:33

because if not, I'm planning to build one <_<


it can be a little difficult to build "canned" components for re-frame because it needs to have all of the subscriptions/effects/etc. registered in the global registry

☝️ 1

so you need to make sure you namespace your keywords, and design it in a way that is flexible enough that applications can easily include and hook into it


@lilactown yeah, another way to do it is that you let the caller provide the keywords to be used when registering things

Braden Shepherdson20:01:42

that's more or less what I'm planning


I'm heading toward the path of having components take subscriptions in their arguments


so the constructor of the component creates the subscription that provides the data


@mattly @braden.shepherdson remember that subscribe takes a vector as its argument, and with components, that vector normally includes an id of some kind to identify the data on which the component is operating. And often that id is really a path within app-db. So your component needs to take arguments, which are path-ish ids, and then you can assemble the vector which is given as an argument to the subscribe. The same can happen with any component-embeded dispatch


i do this in some places as well


dispatching event handlers after an ajax call for example


er wait that's dispatching not subscribing


Apologies if I'm stating the obvious ... but the key insight is that the argument is both subscribe and dispatch is data (a vector). As a result, that data can be "assembled" within a component.


@mattly I'm stressing this point because you talked about components taking subscriptions as arguments. Better, i think, to make the components take data as arguments - data which is then used (within the component) to construct the argument which is given to a subscribe (or dispatch)

👍 1

So I'm encouraging you to be slightly more data oriented.


the thing I work on with re-frame most these days is mostly a internal developer-oriented debugging tool


and as such I've found that I need a lot of "generic" viewing components that can point at any number of data sources


so this practice has stemmed from, I don't want to invent a query grammar on top of subscriptions


Fair enough. Hard for me to comment further on the specifics of your case.


Just trying to throw out ideas