refactor(reactive): remove unnecessary args handling in reactiveEffect (#1593)

This commit is contained in:
Zardddddd60 2020-07-16 11:19:15 +08:00 committed by GitHub
parent 22973b418b
commit ecf872fc95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ type KeyToDepMap = Map<any, Dep>
const targetMap = new WeakMap<any, KeyToDepMap>()
export interface ReactiveEffect<T = any> {
(...args: any[]): T
(): T
_isEffect: true
id: number
active: boolean
@ -77,12 +77,12 @@ export function stop(effect: ReactiveEffect) {
let uid = 0
function createReactiveEffect<T = any>(
fn: (...args: any[]) => T,
fn: () => T,
options: ReactiveEffectOptions
): ReactiveEffect<T> {
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<T = any>(
enableTracking()
effectStack.push(effect)
activeEffect = effect
return fn(...args)
return fn()
} finally {
effectStack.pop()
resetTracking()