I'm trying to activate an action in the execution of a saga, the problem is that the Action is never activated, this is the code:
import firebase from 'react-native-firebase';
function authorize(query) {
console.log(query.size);
if(query.size){
query.forEach(doc => {
console.log(doc.data());
put(loginActions.setLoginSuccess(doc.data()));
});
} else {
put(loginActions.setError({ error: 'El usuario no existe' })); //Nunca se ejecuta esta acción
return undefined;
}
}
export function* loginFlow() {
while (true) {
const {username, password} = yield take(actions.LOGIN_ACTION);
const ref = firebase.firestore().collection('usuarios');
ref
.where('email', "==", username)
.where('contrasena', "==", password)
.onSnapshot(authorize);
}
}
The execution is perfectly carried until the LoginAction.setError arrives, it does not run correctly, I have made a console.log in the reducer, but it never enters. I suppose there must be another way to implement and run the onSnapshot. Agradesco in advance.