( msec: number = DEFAULT_DEBOUNCE_INTERVAL )
| 406 | * @summary  |
| 407 | */ |
| 408 | export function createThrottledEffect( |
| 409 | msec: number = DEFAULT_DEBOUNCE_INTERVAL |
| 410 | ) { |
| 411 | return function < |
| 412 | Request, |
| 413 | Response = void, |
| 414 | TError extends Error = Error, |
| 415 | TState = Response |
| 416 | >( |
| 417 | handler: EffectSource<Request, Response>, |
| 418 | initialState?: TState, |
| 419 | options?: CreateEffectOptions<Request, TError> |
| 420 | ): EffectRunner<Request, Response, TError, TState> { |
| 421 | return createEffect<Request, Response, TError, TState>( |
| 422 | (args: Request) => { |
| 423 | return concat( |
| 424 | // do the work up front |
| 425 | // @ts-ignore |
| 426 | handler(args), |
| 427 | // include the throttling interval |
| 428 | after(msec, EMPTY) |
| 429 | ); |
| 430 | }, |
| 431 | exhaustMap, |
| 432 | initialState, |
| 433 | options |
| 434 | ); |
| 435 | }; |
| 436 | } |
| 437 |
no test coverage detected