@laserware/stasis
    Preparing search index...

    Function takeLeading

    • Spawns a saga on each action dispatched to the Store that matches pattern. After spawning a task once, it blocks until spawned saga completes and then starts to listen for a pattern again.

      In short, takeLeading is listening for the actions when it doesn't run a saga.

      In the following example, we create a basic task fetchUser. We use takeLeading to start a new fetchUser task on each dispatched USER_REQUESTED action. Since takeLeading ignores any new coming task after it's started, we ensure that if a user triggers multiple consecutive USER_REQUESTED actions rapidly, we'll only keep on running with the leading action

      import { takeLeading } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchLastFetchUser() { yield takeLeading('USER_REQUESTED', fetchUser) }

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

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

      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. After spawning a task once, it blocks until spawned saga completes and then starts to listen for a pattern again.

      In short, takeLeading is listening for the actions when it doesn't run a saga.

      In the following example, we create a basic task fetchUser. We use takeLeading to start a new fetchUser task on each dispatched USER_REQUESTED action. Since takeLeading ignores any new coming task after it's started, we ensure that if a user triggers multiple consecutive USER_REQUESTED actions rapidly, we'll only keep on running with the leading action

      import { takeLeading } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchLastFetchUser() { yield takeLeading('USER_REQUESTED', fetchUser) }

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

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

      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. takeLeading 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. After spawning a task once, it blocks until spawned saga completes and then starts to listen for a pattern again.

      In short, takeLeading is listening for the actions when it doesn't run a saga.

      In the following example, we create a basic task fetchUser. We use takeLeading to start a new fetchUser task on each dispatched USER_REQUESTED action. Since takeLeading ignores any new coming task after it's started, we ensure that if a user triggers multiple consecutive USER_REQUESTED actions rapidly, we'll only keep on running with the leading action

      import { takeLeading } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchLastFetchUser() { yield takeLeading('USER_REQUESTED', fetchUser) }

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

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

      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. After spawning a task once, it blocks until spawned saga completes and then starts to listen for a pattern again.

      In short, takeLeading is listening for the actions when it doesn't run a saga.

      In the following example, we create a basic task fetchUser. We use takeLeading to start a new fetchUser task on each dispatched USER_REQUESTED action. Since takeLeading ignores any new coming task after it's started, we ensure that if a user triggers multiple consecutive USER_REQUESTED actions rapidly, we'll only keep on running with the leading action

      import { takeLeading } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchLastFetchUser() { yield takeLeading('USER_REQUESTED', fetchUser) }

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

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

      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. takeLeading 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 takeLeading(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. After spawning a task once, it blocks until spawned saga completes and then starts to listen for a pattern again.

      In short, takeLeading is listening for the actions when it doesn't run a saga.

      In the following example, we create a basic task fetchUser. We use takeLeading to start a new fetchUser task on each dispatched USER_REQUESTED action. Since takeLeading ignores any new coming task after it's started, we ensure that if a user triggers multiple consecutive USER_REQUESTED actions rapidly, we'll only keep on running with the leading action

      import { takeLeading } from redux-saga/effects

      function* fetchUser(action) { ... }

      function* watchLastFetchUser() { yield takeLeading('USER_REQUESTED', fetchUser) }

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

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

      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. takeLeading will add the incoming action to the argument list (i.e. the action will be the last argument provided to saga)

      Returns ForkEffect<never>