鍍金池/ 問答/HTML/ 在 dva 里面怎么做處理異步排隊

在 dva 里面怎么做處理異步排隊

    * deleteDetails({payload}, {call, put}) {
      const result = yield call(deleteDetails, {payload});
      if (result.code !== 200) {
        throw result.msg;
      } else {
        Toast.success(result.msg, 1);
        yield put(routerRedux.goBack())
      }
    },

先執(zhí)行定時提示,完成提示則返回上一頁,這個怎么處理異步排隊

回答
編輯回答
小眼睛

通過call一個Promise來實現(xiàn):

   * deleteDetails({payload}, {call, put}) {
      const result = yield call(deleteDetails, {payload});
      if (result.code !== 200) {
        throw result.msg;
      } else {
          yield call(() => {
            return new Promise((resolve) => {
              Toast.success(result.msg, 1);
              setTimeout(() => resolve(), 1000)
            });
          });
          yield put(routerRedux.goBack())
      }
    }
2018年1月6日 22:08