Passing VM (component instance) into effectScope
#363
MartinMalinda
started this conversation in
RFC Discussions
Replies: 2 comments 4 replies
-
Can you just use getCurrentInstance and onUnmounted? |
Beta Was this translation helpful? Give feedback.
1 reply
-
This is unnecessary because inside |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So there's the new effectScope API which is really nice and it could one issue for me in
vue-concurrency
. But for convenience, I'd need one extra little feature on top.The
effectScope
is mainly created to be able to dispose of effects that are not bound to a particular component. But in my particular usecase I create an object (task) and this object later creates another objects with another effects. This can happen asynchronously (user interaction, XHR etc) and so at that point thecomputed
andwatch
that are used are no longer assigned to current instance. I'd like to "force" that. I know that any such "subobject" (task instance) should still be bound to the parent object which is usually bound to the current component instance.So in brief I'd like to do something like this:
At this point I'd expect
vm
is unmountedvm
is undefined)run
on a scope that is disposed I'd get an error (maybe that happens already)A very simplified example of what
vue-concurrency
is doing:As you can see here, the first
reactive
is created in setup. But the first secondreactive
with the onecomputed
inside is created later in an async function, therefore these are no longer assigned to the current component instance and they probably outlive the component overall.The same could could look like this with the patched
effectScope
:Thanks for reading, any feedback appreciated 🙏
Beta Was this translation helpful? Give feedback.
All reactions