Fork me on GitHub
#om
<
2015-09-21
>
ul09:09:44

Hi, Omists! I need help 😉 I have Om component which I consider opaque for my code, but I want its render function to have some custom var bindings. But (binding [...] (om/build OpaqueComponent ...) does not have desired effect, of course, because render is called not inside this form.

darwin10:09:07

@ul: I’m afraid you would have to take OpaqueComponent and pass a new component to om/build which wraps OpaqueComponent’s IRender or IRenderState functions into your binding form

ul10:09:21

yes, but i'm trying to substitute some global values in OpaqueComponent. I'm using modifed re-frame with Om

ul10:09:43

and now I need to have ability to use multiple app-db

ul10:09:53

one way is to pass it directly as parameter

ul10:09:07

but I want to try first possibility to use binding

ul10:09:02

the point is to make dispatch calls in component to know that they must use another db

ul10:09:18

thank for the idea

ul10:09:25

i first misunderstood it

ul10:09:57

i will build OpaqueComponent and then wrap its render with specify

darwin10:09:30

@ul yes, I’m looking into om sources, you basically have to override IRender and IRenderState methods with your wrappers

darwin10:09:39

an alternative solution would be to write your own re-frame loop and make dispatch function more flexible

darwin10:09:43

this can be done by not requiring re-frame.core and requiring just other namespaces except router, you would have to copy&paste their loop and make needed changes

ul10:09:55

i have custom loop and custom om instrument for subscriptions. so its not a problem to pass db to component and to dispatch from component. but I have ambition to not change component code for passing db to dispatch

ul10:09:26

component just calls dispatch, and which db is used is chosen by wrapper

darwin10:09:28

makes sense, it looks like it is doable with specify!, that is what om uses internally to define various protocol methods when building component

ul16:09:32

@darwin: if you are interested, i solved the problem with providing custom :descriptor for om/build

darwin17:09:06

@ul: yes, I would like to see a gist of it

ul17:09:01

and it is used below in wrapper

darwin17:09:39

@ul: looks good! thanks for sharing, and ampere looks like a cool project, I have one Om project and eventually I would like to switch to re-frame there too

darwin17:09:53

@ul btw. you might want to look at my fork of re-frame, it might be a good fit so ampere does not need to duplicate it