-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a standalone ref/computed properties inside setup. #2057
Comments
Currently, there is a binding relationship between the export interface WritableComputedOptions<T> {
get: ComputedGetter<T>
set: ComputedSetter<T>
global?: boolean
} It's const doubleCount = computed({
get: () => counter.value * 2,
global: true
})
// stop it
stop(doubleCount.effect) // or directly compouted `stop(doubleCount)` Or, we provide a const doubleCount = globalComputed(() => counter.value * 2)
stop(doubleCount.effect) // or directly compouted `stop(doubleCount)` |
Duplicate of #1532 |
@HcySunYang I think it's worth posting that comment on the other issue. It has useful information. |
On Sun, 2020-09-06 at 01:05 -0700, Eduardo San Martin Morote wrote:
Closed #2057.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Looks like this one is a partial duplicate, it doesn't cover a case
with a different standalone ref behaviour. Even if an additional global
or a manual clean-up option is implemented, it doesn't cover why ref is
still being active after a component was unmounted. Depending on a
reactivity implementation, it may cause a leak. My guess would be that
a standalone ref should behave the same way as a computed prop or watch
case described in #1532, with the same additional setup to explicitly
indicate that it not a part of a current component lifecycle. Or if it
is not the case, hopefully the guide will be updated.
|
Version
3.0.0-rc.10
Reproduction link
https://github.com/an-sh/standalone-computed-test
Steps to reproduce
Create a singleton class with ref and computed properties inside component's setup.
Use a singleton instance in a component that goes through several mount/unmount cycles.
What is expected?
ref and computed properties should behave the same way
What is actually happening?
Ref property stays reactive for all component instances , however a computed property will stop being reactive after the first component instance is unmounted.
Not sure what exactly should happen, it is easy to assume that anything created during a setup call should be coupled with a components life-cycle. But i don't see any options to enforce ref/computed values to be indefinitely global or be disposed at a certain point outside of components logic (like rxjs unsubscribe).
The text was updated successfully, but these errors were encountered: