From ecf872fc951707976a0a502c5c86356a85f75fec Mon Sep 17 00:00:00 2001 From: Zardddddd60 Date: Thu, 16 Jul 2020 11:19:15 +0800 Subject: [PATCH] refactor(reactive): remove unnecessary args handling in reactiveEffect (#1593) --- packages/reactivity/src/effect.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index 03f8e510..eb06a63a 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -10,7 +10,7 @@ type KeyToDepMap = Map const targetMap = new WeakMap() export interface ReactiveEffect { - (...args: any[]): T + (): T _isEffect: true id: number active: boolean @@ -77,12 +77,12 @@ export function stop(effect: ReactiveEffect) { let uid = 0 function createReactiveEffect( - fn: (...args: any[]) => T, + fn: () => T, options: ReactiveEffectOptions ): ReactiveEffect { - const effect = function reactiveEffect(...args: unknown[]): unknown { + const effect = function reactiveEffect(): unknown { if (!effect.active) { - return options.scheduler ? undefined : fn(...args) + return options.scheduler ? undefined : fn() } if (!effectStack.includes(effect)) { cleanup(effect) @@ -90,7 +90,7 @@ function createReactiveEffect( enableTracking() effectStack.push(effect) activeEffect = effect - return fn(...args) + return fn() } finally { effectStack.pop() resetTracking()