Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are reagent-forms meant to be using with re-frame?

I'm building an application with re-frame and I'm wondering if reagent-form are meant to be used with re-frame or not, as reagent-form brings in its own way of handling state which is different than re-frame.

like image 535
pupeno Avatar asked Oct 08 '15 18:10

pupeno


People also ask

What is re-frame in ClojureScript?

re-frame is an application framework for creating more complex single page applications [SPAs] in ClojureScript, using Reagent and [hiccup] style description for generating content.

What is reframe Clojure?

From OO to Clojure Workshop! Re-frame is the most popular frontend framework for ClojureScript. It is built on Reagent, and thus React. Re-frame adds a beneficial amount of structure to build and maintain your frontend applications.


2 Answers

After experimenting a bit, I'd say it can be used, by completely ignoring the ratom that reagent-forms use for state and just using the callback, as in:

[bind-fields [form-template ...] default-values
               (fn [_ _ doc]
                 (re-frame.core/dispatch [:update-data doc]))]

but to me, it didn't feel right, ignoring that ratom with state. That's why I created a new library called Free-form for creating forms with Reagent and optionally, with Re-frame.

Free-form doesn't store state, it just has a similar callback mechanism and it comes with a layer that makes it plugging it into Re-frame straightforward (but optional). On top of that, it makes no assumptions about the shape of your form, you are in total control of your HTML.

like image 77
pupeno Avatar answered Sep 22 '22 07:09

pupeno


You can, but I think you shouldn't.

One thing you could do is just require twitter bootstrap and do some glueing to use everything in the re-frame way.

like image 20
thiagofm Avatar answered Sep 22 '22 07:09

thiagofm