如何知道redux-saga传奇何时完成?

时间:2019-01-25 14:56:04

标签: javascript redux redux-saga next.js

我正在使用next-redux-saga在NextJS上下文中使用redux-saga。文档说

 /**
   * next-redux-saga depends on `runSagaTask` and `sagaTask` being attached to the store.
   *
   *   `runSagaTask` is used to rerun the rootSaga on the client when in sync mode (default)
   *   `sagaTask` is used to await the rootSaga task before sending results to the client
   *
   */

  store.runSagaTask = () => {
    store.sagaTask = sagaMiddleware.run(rootSaga)
  }

如果我的传奇故事正在这样获取数据:

function * loadDataSaga () {
  try {
    console.log('fetching data in saga')

    const res = yield fetch('https://jsonplaceholder.typicode.com/users')
    const data = yield res.json()
    yield put(loadDataSuccess(data))
  } catch (err) {
    yield put(failure(err))
  }
}

next-redux-saga如何知道传奇完成的时间,即我假设的数据加载时间?

0 个答案:

没有答案