For example, this is nice:
// On login, spin off the auth process. If an error or a logout happens, clean up.
// Be sure to cancel any pending auth request!
// Then get ready for a new login.
function* loginFlow() {
while (true) {
const {user, password} = yield take('LOGIN_REQUEST')
const task = yield fork(authorize, user, password)
const action = yield take(['LOGOUT', 'LOGIN_ERROR'])
if (action.type === 'LOGOUT')
yield cancel(task)
yield call(Api.clearItem, 'token')
}
}
(Genuine question...idk!)