@laserware/stasis
    Preparing search index...

    Function takeEvery

    • Spawns a saga on each action dispatched to the Store that matches pattern.

      In the following example, we create a basic task fetchUser. We use takeEvery to start a new fetchUser task on each dispatched USER_REQUESTED action:

      import { takeEvery } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchFetchUser() { yield takeEvery('USER_REQUESTED', fetchUser) }

      takeEvery is a high-level API built using take and fork. Here is how the helper could be implemented using the low-level Effects

      const takeEvery = (patternOrChannel, saga, ...args) => fork(function*() { while (true) { const action = yield take(patternOrChannel) yield fork(saga, ...args.concat(action)) } })

      takeEvery allows concurrent actions to be handled. In the example above, when a USER_REQUESTED action is dispatched, a new fetchUser task is started even if a previous fetchUser is still pending (for example, the user clicks on a Load User button 2 consecutive times at a rapid rate, the 2nd click will dispatch a USER_REQUESTED action while the fetchUser fired on the first one hasn't yet terminated)

      takeEvery doesn't handle out of order responses from tasks. There is no guarantee that the tasks will terminate in the same order they were started. To handle out of order responses, you may consider takeLatest below.

      Type Parameters

      • P extends ActionPattern

      Parameters

      • pattern: P

        for more information see docs for take(pattern)

      • worker: (action: ActionMatchingPattern<P>) => any

      Returns ForkEffect<never>

    • Spawns a saga on each action dispatched to the Store that matches pattern.

      In the following example, we create a basic task fetchUser. We use takeEvery to start a new fetchUser task on each dispatched USER_REQUESTED action:

      import { takeEvery } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchFetchUser() { yield takeEvery('USER_REQUESTED', fetchUser) }

      takeEvery is a high-level API built using take and fork. Here is how the helper could be implemented using the low-level Effects

      const takeEvery = (patternOrChannel, saga, ...args) => fork(function*() { while (true) { const action = yield take(patternOrChannel) yield fork(saga, ...args.concat(action)) } })

      takeEvery allows concurrent actions to be handled. In the example above, when a USER_REQUESTED action is dispatched, a new fetchUser task is started even if a previous fetchUser is still pending (for example, the user clicks on a Load User button 2 consecutive times at a rapid rate, the 2nd click will dispatch a USER_REQUESTED action while the fetchUser fired on the first one hasn't yet terminated)

      takeEvery doesn't handle out of order responses from tasks. There is no guarantee that the tasks will terminate in the same order they were started. To handle out of order responses, you may consider takeLatest below.

      Type Parameters

      • P extends ActionPattern
      • Fn extends (...args: any[]) => any

      Parameters

      • pattern: P

        for more information see docs for take(pattern)

      • worker: Fn
      • ...args: HelperWorkerParameters<ActionMatchingPattern<P>, Fn>

        arguments to be passed to the started task. takeEvery will add the incoming action to the argument list (i.e. the action will be the last argument provided to saga)

      Returns ForkEffect<never>

    • Spawns a saga on each action dispatched to the Store that matches pattern.

      In the following example, we create a basic task fetchUser. We use takeEvery to start a new fetchUser task on each dispatched USER_REQUESTED action:

      import { takeEvery } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchFetchUser() { yield takeEvery('USER_REQUESTED', fetchUser) }

      takeEvery is a high-level API built using take and fork. Here is how the helper could be implemented using the low-level Effects

      const takeEvery = (patternOrChannel, saga, ...args) => fork(function*() { while (true) { const action = yield take(patternOrChannel) yield fork(saga, ...args.concat(action)) } })

      takeEvery allows concurrent actions to be handled. In the example above, when a USER_REQUESTED action is dispatched, a new fetchUser task is started even if a previous fetchUser is still pending (for example, the user clicks on a Load User button 2 consecutive times at a rapid rate, the 2nd click will dispatch a USER_REQUESTED action while the fetchUser fired on the first one hasn't yet terminated)

      takeEvery doesn't handle out of order responses from tasks. There is no guarantee that the tasks will terminate in the same order they were started. To handle out of order responses, you may consider takeLatest below.

      Type Parameters

      • A extends Action

      Parameters

      • pattern: ActionPattern<A>

        for more information see docs for take(pattern)

      • worker: (action: A) => any

      Returns ForkEffect<never>

    • Spawns a saga on each action dispatched to the Store that matches pattern.

      In the following example, we create a basic task fetchUser. We use takeEvery to start a new fetchUser task on each dispatched USER_REQUESTED action:

      import { takeEvery } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchFetchUser() { yield takeEvery('USER_REQUESTED', fetchUser) }

      takeEvery is a high-level API built using take and fork. Here is how the helper could be implemented using the low-level Effects

      const takeEvery = (patternOrChannel, saga, ...args) => fork(function*() { while (true) { const action = yield take(patternOrChannel) yield fork(saga, ...args.concat(action)) } })

      takeEvery allows concurrent actions to be handled. In the example above, when a USER_REQUESTED action is dispatched, a new fetchUser task is started even if a previous fetchUser is still pending (for example, the user clicks on a Load User button 2 consecutive times at a rapid rate, the 2nd click will dispatch a USER_REQUESTED action while the fetchUser fired on the first one hasn't yet terminated)

      takeEvery doesn't handle out of order responses from tasks. There is no guarantee that the tasks will terminate in the same order they were started. To handle out of order responses, you may consider takeLatest below.

      Type Parameters

      • A extends Action
      • Fn extends (...args: any[]) => any

      Parameters

      • pattern: ActionPattern<A>

        for more information see docs for take(pattern)

      • worker: Fn
      • ...args: HelperWorkerParameters<A, Fn>

        arguments to be passed to the started task. takeEvery will add the incoming action to the argument list (i.e. the action will be the last argument provided to saga)

      Returns ForkEffect<never>

    • You can also pass in a channel as argument and the behaviour is the same as takeEvery(pattern, saga, ...args).

      Type Parameters

      • T

      Parameters

      • channel: TakeableChannel<T>
      • worker: (item: T) => any

      Returns ForkEffect<never>

    • Spawns a saga on each action dispatched to the Store that matches pattern.

      In the following example, we create a basic task fetchUser. We use takeEvery to start a new fetchUser task on each dispatched USER_REQUESTED action:

      import { takeEvery } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchFetchUser() { yield takeEvery('USER_REQUESTED', fetchUser) }

      takeEvery is a high-level API built using take and fork. Here is how the helper could be implemented using the low-level Effects

      const takeEvery = (patternOrChannel, saga, ...args) => fork(function*() { while (true) { const action = yield take(patternOrChannel) yield fork(saga, ...args.concat(action)) } })

      takeEvery allows concurrent actions to be handled. In the example above, when a USER_REQUESTED action is dispatched, a new fetchUser task is started even if a previous fetchUser is still pending (for example, the user clicks on a Load User button 2 consecutive times at a rapid rate, the 2nd click will dispatch a USER_REQUESTED action while the fetchUser fired on the first one hasn't yet terminated)

      takeEvery doesn't handle out of order responses from tasks. There is no guarantee that the tasks will terminate in the same order they were started. To handle out of order responses, you may consider takeLatest below.

      Type Parameters

      • T
      • Fn extends (...args: any[]) => any

      Parameters

      • channel: TakeableChannel<T>
      • worker: Fn
      • ...args: HelperWorkerParameters<T, Fn>

        arguments to be passed to the started task. takeEvery will add the incoming action to the argument list (i.e. the action will be the last argument provided to saga)

      Returns ForkEffect<never>