Open Floriferous opened 6 years ago
@Floriferous dispatching actions that in turn call promises and dispatch other actions is not yet supported, but the middleware to do this is already under way within redux-firestore (though it is not yet finished or documented).
The documentation is going to look something like the following (note that none of the provided examples will work yet since this has not been released):
redux-firestore
's enhancer offers a new middleware setup that was not offered in react-redux-firebase
(but will eventually be ported)
Note: This syntax is just a sample and is not currently released
Still undermined - could be included with reduxFirestore
store enhancer or may need to be added separately as its own reduxFirestoreAsyncMiddleware
(or a similar name)
Direct Dispatch
import { FIREBASE_CALL } from 'react-redux-firebase'
dispatch({
type: FIREBASE_CALL,
collection: 'users', // only used when namespace is firestore
method: 'push' // get method
args: [{ newData: 'test' }]
})
Action Creator
import { actionCreators } from 'react-redux-firebase'
dispatch(actionCreators.push({ collection: 'users' }, { newData: 'test' }))
Some of the goals behind this approach include:
react-redux-firebase
this means using getFirebase
and/or firebaseConnect
/withFirebase
HOCs)
In my thunks where I somehow access the database, I always have to extract firebase first, before injecting it inside a module that should hide firebase as much as possible:
Is there a way to write these more like this, and remove all the firebase access from thunks? :