core icon indicating copy to clipboard operation
core copied to clipboard

feat(app): support app level effect scope

Open Mini-ghost opened this issue 2 years ago • 7 comments

close #8787

Mini-ghost avatar Jul 17 '23 18:07 Mini-ghost

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

posva avatar Aug 09 '23 08:08 posva

Thank you for your feedback. I have a couple of questions I would like to confirm:

  1. In #4619, the implementation of adding app.onUnmount functionality is located in runtime-core/src/apiCreateApp.ts instead of runtime-dom/src/index.ts. I'm not sure if this PR should follow this approach.

  2. Currently, Vue internally utilizes the new EffectScope(true) approach. Would it be advisable for this PR to adopt a class-based approach instead of using effectScope(true)?

Thank you! Your invaluable guidance means a lot to me.

Mini-ghost avatar Aug 09 '23 16:08 Mini-ghost

  1. I think yes, I don't see why this should be in runtime-dom instead of core
  2. I'm not sure but I don't think it matters

posva avatar Aug 09 '23 16:08 posva

I have moved the implementation to runtime-core and added a test case. Could you please review?

Mini-ghost avatar Aug 09 '23 17:08 Mini-ghost