How to achieve callbacks in Redux-Saga? : <p>The scenario is, I want to redirect a user or show alert based on the success, error callbacks after dispatching an action.</p>

<p>Below is the code using <strong>redux-thunk</strong> for the task</p>

<pre><code>this.props.actions.login(credentials)
.then((success)=&gt;redirectToHomePage)
.catch((error)=&gt;alertError);
</code></pre>

<p>because the dispatch action in redux-thunk returns a Promise, It is easy to act with the response. </p>

<p>But now I'm getting my hands dirty on redux-saga, and trying to figure out how I can achieve the same result as above code. since Saga's run on a different thread, there is no way I can get the callback from the query above. so I just wanted to know how you guys do it. or whats the best way to deal with callbacks while using redux-saga ?
the dispatch action looks like this :</p>

<blockquote>
  <p>this.props.actions.login(credentials);</p>
</blockquote>

<p>and the saga   </p>

<pre><code>function* login(action) {
  try {
    const state = yield select();
    const token = state.authReducer.token;
    const response = yield call(API.login,action.params,token);
    yield put({type: ACTION_TYPES.LOGIN_SUCCESS, payload:response.data});
    yield call(setItem,AUTH_STORAGE_KEY,response.data.api_token);
  } catch (error) {
    yield put({type: ACTION_TYPES.LOGIN_FAILURE, error})
  }
}
</code></pre>

<p>saga monitor</p>

<pre><code>export function* loginMonitor() {
  yield takeLatest(ACTION_TYPES.LOGIN_REQUEST,login);
}
</code></pre>

<p>action creator</p>

<pre><code>function login(params) {
  return {
    type: ACTION_TYPES.LOGIN_REQUEST,
    params
  }
}
</code></pre>
