S
S
Seva2018-02-09 16:06:12
JavaScript
Seva, 2018-02-09 16:06:12

[ redux-saga ] Why does a saga only run once?

const signIn = function* signIn() {
  while (true) {
    const request = yield take(LOGIN_REQUEST);
    try {
      response = yield call(AuthService.signIn, { login: request.data.login, password: request.data.password });
    } catch (error) {
      return alert(error);
    }
    yield put({ type: SET_AUTH, username: request.data.login });
    yield put({ type: RESET_TO_MAIN });
  }
}

If the promise is rejected, an error alert is thrown, but the Saga is no longer called and does not work. What am I doing wrong?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2018-02-09
@davidnum95

When it comes to return, the function exits.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question