A
A
Arthur2020-09-20 23:47:17
redux
Arthur, 2020-09-20 23:47:17

What is the correct way to call a saga from another saga?

there is a query call saga

\\pseudocode

getDataWorker* (action) {
  try {
    data = yield getData()
    yield put(getDataSuccess(data))
  } catch(error) {
    yield put(getDataError(error))
  }
}

watcher* () {
  yield takeEvery(getDataRequest, getDataWorker)
}


How to call such a saga for example in another saga?
Trigger it with the same request so that the watcher works and catch success or error?
for example like this:

AnotherWorker* (action) {
  yield put(getDataRequest())
  yield take(getDataSuccess)
  data = yield select(data)
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question