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
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
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
effectScopeis 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 thecomputedandwatchthat 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
vmis unmountedvmis undefined)runon a scope that is disposed I'd get an error (maybe that happens already)A very simplified example of what
vue-concurrencyis doing:As you can see here, the first
reactiveis created in setup. But the first secondreactivewith the onecomputedinside 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