此 saga 与LOGIN_SUCCESS
操作一起使用并正确保存数据。但是在那之后它永远不会对LOGOUT_SUCCESS
function *persistAccount() {
while (true) {
const result = yield take([actions.LOGIN_SUCCESS, actions.USER_UPDATED, actions.LOGOUT_SUCCESS])
console.info("Got persist action")
switch (result.type) {
case actions.LOGIN_SUCCESS:
case actions.USER_UPDATED:
console.info("Updating credentials")
if (result.access_token) {
localStorage["access_token"] = result.access_token
}
if (result.user) {
localStorage["user"] = JSON.stringify(result.user)
}
break
case action.LOGOUT_SUCCESS:
debugger
console.info("Clearing credentials")
localStorage.removeItem("access_token")
localStorage.removeItem("user")
break
}
}
console.info("!!!!!!!!!!!!!!!!!!!EXIT")
}
它也永远不会完成,因为这会将最后一行中的文本打印到控制台。
这是怎么回事?