hoppula / refire

Declarative Firebase bindings for Redux and React
46 stars 9 forks source link

redux mutations trigger update in firebase. #2

Closed walkerrandolphsmith closed 8 years ago

walkerrandolphsmith commented 8 years ago

I have been able to connect my components with react-redux and refire, but I am unsure how to allow redux to manage state mutations and update firebase with newest state. I have considered subscribing to store and sending the (subset) of the store to firebase on changes. I have also considered updating firebase in redux-thunks, but realize that state mutations would be handled in action creators and not reducers. I am trying to accomplish:

Maintain a set of semantic action creators, reducers handle state mutations, firebase is updated when redux store changes, listen to firebase changes and dispatch the appropriate actions on changes.

Is this library intended to solve updating firebase from local redux store changes?

hoppula commented 8 years ago

This library only syncs from Firebase to redux to keep things simple, so you'll have to use the Firebase client's write methods to update the external Firebase state.

You can also use the FirebaseWrite higher order component for mutations, good usage example would be: ReplyToThread.js in refire-forum.

ReplyToThread receives submit method as a prop from FirebaseWrite and the reply data is constructed in updates.js.

refire automatically syncs data from Firebase after submit for the current user and all other connected users.

walkerrandolphsmith commented 8 years ago

Okay thank you for the clarification! Great work.