salsita / prism

React / Redux action composition made simple http://salsita.github.io/prism/
495 stars 24 forks source link

Forms #29

Closed jmarceli closed 8 years ago

jmarceli commented 8 years ago

Like in any other framework there has to be some simple way of handling forms. Until now I was using redux-form but it is not "compatible" with Elm Architecture idea. What do you think about that? Do know any alternatives which might be used with redux-elm?

jmarceli commented 8 years ago

I've manage to made a sample redux-form integration. Here is the repo https://github.com/jmarceli/redux-elm-form. If you will have some spare time please take a look and tell me if it suits you. If so I can make some pull requests to the documentation section and explain the integration. Probably there should be separate chapter called "Integration with other packages" or something like that. I know that storing forms outside regular Elm tree is not the way it should be handled but this is the only (successful) way of integrating redux-form (I have no luck with trying to make separate form for each component - but it might be possible).

A couple of issues I come across while making this sample app:

tomkis commented 8 years ago

Hello, I really appreciate what you did here. I am working on this issue today and came to basically same implementation. However, I am not sure how much aware you are of v6 of redux-form since there will be many breaking changes which will basically not allow this approach.

My main concern is that in v6, only fields will be connected not the entire form, the issue is though that there's no simple way to provide the field with wrapped dispatch function. I am thinking about filing an issue to redux-form repo.

jmarceli commented 8 years ago

Hi. I'm aware that it will be v6 but I didn't check how much changes it will bring. It's definitely good idea to submit an issue, but I don't know if eventually it will be necessary to provide some Elm-compatible implementation of the forms (or some kind of adapter for redux-form).

Offtopic question: Do you manage to run/deliver any production services based on redux-elm? I'm asking because I have to write an app for the client and composability of the Elm Architecture seems to be a good solution.

tomkis commented 8 years ago

@jmarceli after deep understanding of how redux-form works I've decided to send a PR, https://github.com/erikras/redux-form/pull/1154 let's see where it gets us.

OT answer: Yes, we are in the middle of implementing universal web app which is using redux-elm and so far we are happy with the architecture.

jmarceli commented 8 years ago

Thanks for handling this issue. I think that my current level of knowledge won't allow me to create valuable pull request for redux-form project.

jmarceli commented 8 years ago

@tomkis1 maybe I solve the redux-form v6 issue without any modifications to the library. Please take a look at: https://github.com/jmarceli/redux-elm-form/tree/redux_form_v6

I'm not sure if wrapping a form in subcomponent solves all the issues but it allows me to handle form submit with redux-elm custom dispatcher (which was the problem as far as I know).

tomkis commented 8 years ago

So we've come up with a conclusion that redux-form is quite opinionated library even in plain redux which makes it even more difficult to integrate with redux-elm. Maybe more focused library would do the trick better.