From 76026dfa69603180d1e67df628226685a9618409 Mon Sep 17 00:00:00 2001 From: AlexandrHoroshih Date: Sat, 18 Nov 2023 18:16:52 +0700 Subject: [PATCH] Fix `name` support in debounce --- src/debounce/index.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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,