1

このサガは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")
}

また、最終行のテキストがコンソールに出力されるため、決して終了しません。

どうしたの?

4

1 に答える 1

0

見るのにこんなに時間がかかったなんて信じられない。それはタイプミスです:

case action.LOGOUT_SUCCESS:

する必要があります:

case actions.LOGOUT_SUCCESS: // "actions" instead of "action"
于 2016-03-06T00:50:16.087 に答える