0

Reading documentation for https://github.com/redux-saga/redux-saga and they have a notation on function i am not familiar with:

// worker Saga: will be fired on USER_FETCH_REQUESTED actions
function* fetchUser(action) {
   try {
      const user = yield call(Api.fetchUser, action.payload.userId);
      yield put({type: "USER_FETCH_SUCCEEDED", user: user});
   } catch (e) {
      yield put({type: "USER_FETCH_FAILED", message: e.message});
   }
}

what does the function* mean?

pgee70
  • 3,707
  • 4
  • 35
  • 41
  • 2
    yeah, hard to search for that because of the `*` - see - [function* docs](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/function*) – Jaromanda X Jun 22 '17 at 01:40
  • In case of redux-saga, generator functions is used for support potential infinite event loop of asynchronous methods. Generally, generators delegate async/wait infrastructure to caller. See https://github.com/tj/co for classic implementation – Vladislav Ihost Jun 26 '17 at 07:39

0 Answers0