core
core copied to clipboard
feat(app): support app level effect scope
close #8787
This would potentially also enable an app.onUnmount() with just one line
app.onUnmount = (fn) => app.runWithContext(() => onScopeDispose(fn))
- https://github.com/vuejs/core/pull/4619
- https://github.com/vuejs/core/issues/4516
Thank you for your feedback. I have a couple of questions I would like to confirm:
-
In #4619, the implementation of adding
app.onUnmountfunctionality is located inruntime-core/src/apiCreateApp.tsinstead ofruntime-dom/src/index.ts. I'm not sure if this PR should follow this approach. -
Currently, Vue internally utilizes the
new EffectScope(true)approach. Would it be advisable for this PR to adopt a class-based approach instead of usingeffectScope(true)?
Thank you! Your invaluable guidance means a lot to me.
- I think yes, I don't see why this should be in runtime-dom instead of core
- I'm not sure but I don't think it matters
I have moved the implementation to runtime-core and added a test case. Could you please review?