MCPcopy Create free account
hub / github.com/deanrad/rxfx / createDebouncedEffect

Function createDebouncedEffect

effect/src/createEffect.ts:408–434  ·  view source on GitHub ↗
(
  msec: number = DEFAULT_DEBOUNCE_INTERVAL
)

Source from the content-addressed store, hash-verified

406 * @summary ![blocking mode](https://d2jksv3bi9fv68.cloudfront.net/rxfx/mode-blocking-sm.png)
407 */
408export 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

Callers 1

Calls 3

afterFunction · 0.90
createEffectFunction · 0.85
handlerFunction · 0.50

Tested by

no test coverage detected