Skip to content

feat(app.runWithContext): Support getCurrentInstance #8594

Open
@Heniker

Description

@Heniker

What problem does this feature solve?

When getCurrentInstance is used within app.runWithContext - top-level component instance should be returned (if it already exists). This should allow easier usage of Vue features outside components.

This behavior can currently be 'emulated' with app.provide, but it feels like there should be no need for this workaround.

runWithContext was first introduced in #7451

What does the proposed API look like?

const app = createApp(App)
app.mount('#app')
app.runWithContext(() => {
  getCurrentInstance() === app._instance // true
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✨ feature requestNew feature or requesthas workaroundA workaround has been found to avoid the problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions