Make getters in reactive cacheable #6297
Kolobok12309
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
if (!computedRef) {
computedRef = computed(() => Reflect.get(target, key, receiver));
targetGetterMap.set(key, computedRef);
} Changes to target[key] in the code do not cause updates to the computed value. Here it's just a read of the value and there is no performance penalty. In contrast, using |
Beta Was this translation helpful? Give feedback.
2 replies
-
In the computed's core/packages/reactivity/src/computed.ts Lines 55 to 64 in a95554d |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While using vue3, i try js classes for my data and some plugins(this works great with
typescript
andclass-transformer
), getters also works reactively, but not cached.Example:
Perhaps this may interfere with someone in the case of side effects in the getter, but I see no other reason not to implement caching
For setters same situation, but currently i don't use them
My first raw realization
It will probably be useful for someone too.
Beta Was this translation helpful? Give feedback.
All reactions