I am building react-native app, where I use react-native-firebase
and redux-saga
. This is my first project using redux-saga
, hence I am learning. So far I got the authentication of the user using the following:
import firebase from 'react-native-firebase';
function* loginEmlPwdSaga(action) {
try {
const auth = firebase.auth();
const data = yield call(
[auth, auth.signInAndRetrieveDataWithEmailAndPassword],
action.email,
action.password,
);
yield put(loginSuccess(data));
} catch (error) {
yield put(loginFail(error));
}
}
However, now I am stuck at the point, where I want to subscribe to the collection. In react-native-firebase
I would use the following:
firebase.firestore().collection('users').onSnapshot(...)
I am not sure what is the best approach to handle subscribes in redux-saga
. Can you show me the pattern that I can use for the future usage of onSnapshots (testable one)?