Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Redux structure with Firebase in Android

I'm recently new using Redux and I wanted to create a simple app with it. I already did the main structure with my own State, Reducer and Action implementation.

But I'm wondering how can I add the "data" part to the application using Firebase. With this I mean which can be the best practice to structure and externalize the data calls following the pattern of application State of Redux. I already thinked about create a controller and dispatch actions which call the data, but Firebase use a lot of callbacks so I don't find a good way to manage them all following this pattern.

What good practices are there to structure data model in an Android application following the Redux pattern?

like image 825
Francisco Durdin Garcia Avatar asked Oct 11 '16 13:10

Francisco Durdin Garcia


1 Answers

I've been working through this in one of my own apps, using Redux and Firebase. What I've used is something akin to what is described in this blog post on making a react, redux, firebase app with auth.

Basically, you create actions that start the listening to changes in the Firebase data and then when they get those changes they dispatch the new data with an appropriate action (CREATE_ENTITY, UPDATE_ENTITY, DELETE_ENTITY, etc) so that you can make the correct changes in your reducers.

These actions are called when your app starts up since they are needed in order to listen to all data changes in Firebase.

like image 69
jasonmerino Avatar answered Oct 19 '22 23:10

jasonmerino