Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for re-frame #49

Open
timgilbert opened this issue Apr 1, 2015 · 5 comments
Open

Support for re-frame #49

timgilbert opened this issue Apr 1, 2015 · 5 comments

Comments

@timgilbert
Copy link

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
Copy link

@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
Copy link
Author

@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
Copy link

@timgilbert Sounds about right to me :)

@apfelstrudels
Copy link

apfelstrudels commented Apr 22, 2016

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

@sitepodmatt
Copy link

sitepodmatt commented Sep 25, 2016

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants