perf(reactivity): improve reactive effect memory usage (#4001)
Based on #2345 , but with smaller API change - Use class implementation for `ReactiveEffect` - Switch internal creation of effects to use the class constructor - Avoid options object allocation - Avoid creating bound effect runner function (used in schedulers) when not necessary. - Consumes ~17% less memory compared to last commit - Introduces a very minor breaking change: the `scheduler` option passed to `effect` no longer receives the runner function.
This commit is contained in:
@@ -2,7 +2,6 @@ import {
|
||||
computed,
|
||||
reactive,
|
||||
effect,
|
||||
stop,
|
||||
ref,
|
||||
WritableComputedRef,
|
||||
isReadonly
|
||||
@@ -125,7 +124,7 @@ describe('reactivity/computed', () => {
|
||||
expect(dummy).toBe(undefined)
|
||||
value.foo = 1
|
||||
expect(dummy).toBe(1)
|
||||
stop(cValue.effect)
|
||||
cValue.effect.stop()
|
||||
value.foo = 2
|
||||
expect(dummy).toBe(1)
|
||||
})
|
||||
@@ -196,7 +195,7 @@ describe('reactivity/computed', () => {
|
||||
|
||||
it('should expose value when stopped', () => {
|
||||
const x = computed(() => 1)
|
||||
stop(x.effect)
|
||||
x.effect.stop()
|
||||
expect(x.value).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user