ckirkendall / kioo

Enlive/Enfocus style templating for Facebook's React and Om in ClojureScript.
Eclipse Public License 1.0
404 stars 39 forks source link

Support for re-frame #49

Open timgilbert opened 9 years ago

timgilbert commented 9 years ago

It would be great if kioo offered support for the relatively new reagent library re-frame. I've been messing around with it and have been able to get it working, somewhat, with kioo's reagent support, but the difficulty is that kioo only seems to generate "Form 1" (using re-frame's terminology) components, so it's difficult to chain reactions together and you wind up having to write a lot of messy wrapper code.

I'm not entirely sure what a pleasant kioo interface to this would be, since defsnippet and friends already have fairly long and complex sets of arguments, but some way to specify a let-binding on initialization (rather than render) which could let the user bind stuff to re-frame/subscribe might work out well.

I may try to play around with this a bit myself, but I still don't understand kioo's internals terribly well and as I said I don't have a clear idea of what an ideal interface would look like in the first place.

spalladino commented 8 years ago

@timgilbert have you had success with this? I got stuck at the same point ("Form 1" components), and would like to test how kioo behaves in a re-frame app.

timgilbert commented 8 years ago

@spalladino, I never did, no. However, my impression is that you can use the (listen :on-mount) and (listen :on-render) kioo functions to basically achieve the same thing. What re-frame refers to as a Form-2 component is essentially one where the outer function is called on-mount and the inner function that it returns is called on-render. I haven't actually tried this out in a project to see how it would look, though.

kristianmandrup commented 8 years ago

@timgilbert Sounds about right to me :)

apfelstrudels commented 8 years ago

Just do this: (defn comp-form2 [] (let [thing (re-frame/subscribe [:thing])] (deftemplate comp-form1 "templates/thingy.html" … @thing …) comp-form1)))

sitepodmatt commented 7 years ago

So Im thinking about this today, couldn't one just use the form-1 style that kioo generates, and do the form-2 subscriptions in a high-level component e.g. (defn comp-form2 [] (let [thing (re-frame/subscribe [:thing])] [:div [kioo-comp-form1 @thing]])

Or is this what you a referring to by messy wrapper?