diff --git a/src/debounce/index.ts b/src/debounce/index.ts index b39e84c1..66aee473 100644 --- a/src/debounce/index.ts +++ b/src/debounce/index.ts @@ -9,31 +9,33 @@ import { attach, merge, UnitTargetable, - EventAsReturnType + EventAsReturnType, } from 'effector'; export function debounce(_: { source: Unit; timeout: number | Store; + name?: string; }): EventAsReturnType; export function debounce< T, - Target extends - | UnitTargetable - | UnitTargetable, + Target extends UnitTargetable | UnitTargetable, >(_: { source: Unit; timeout: number | Store; target: Target; + name?: string; }): Target; export function debounce({ source, timeout, target, + name, }: { source: Unit; timeout?: number | Store; - target?: UnitTargetable | Unit + target?: UnitTargetable | Unit; + name?: string; }): typeof target extends undefined ? EventAsReturnType : typeof target { if (!is.unit(source)) throw new TypeError('source must be unit from effector'); @@ -69,7 +71,7 @@ export function debounce({ }); }); const timerFx = attach({ - name: `debounce(${(source as any)?.shortName || source.kind}) effect`, + name: name || `debounce(${(source as any)?.shortName || source.kind}) effect`, source: { timeoutId: $timeoutId, rejectPromise: $rejecter,