flipace / lovli.js

A boilerplate for developing react+redux applications with rethinkdb/horizon as realtime database and express for the server.
MIT License
558 stars 35 forks source link

Best use case with Redux? #23

Closed ddaaggeett closed 7 years ago

ddaaggeett commented 7 years ago

Hello, @flipace -

I've recently come across both your boilerplate and another repository by @shanecav - horizon-redux.

I noticed Redux is no longer part of lovli.js, and am wondering if this is because it's expected there to be better methods of implementation by others in the community. Would you consider horizon-redux to be the best method of practice to include Redux with Horizon? If so, should it be included in the boilerplate?

flipace commented 7 years ago

Hi @ddaaggeett, the reason I removed redux is quiet simple - it adds a dependency which might not be needed for many people or would be replaced by a different solution (mobx, cerebral, you name it).

horizon-redux certainly looks great though! I think it'd also work nicely together with horizon-react - i did however not try it.

I would not include it in this boilerplate for the aforementioned reason :)

shanecav commented 7 years ago

Hi @ddaaggeett, I would also add that there's not really an overall "best" method of connecting Horizon and Redux.

The intended use of horizon-redux is to simply convert Horizon data/updates to Redux actions, in order to maintain that data in your Redux state. Something like redux-observable could be used to accomplish the same thing. There are other options to accomplish this as well, e.g. with redux saga. Which option you choose just depends on your requirements and preferences.

This boilerplate uses horizon-react to connect Horizon data directly to components through HOCs, which is a different approach from managing that data in a global store, so it makes sense that Redux (and some Horizon-to-Redux glue such as horizon-redux) wouldn't be included here.