Skip to content

Access global properties in Store #49

@parker-codes

Description

@parker-codes

There is currently no documented way to access Vue root plugins, such as this.$axios or this.$router like I might do in Nuxt. I feel that this is a very common use case since the Vue plugin ecosystem is large.

Since binding this is not the way forward, can we have a way to get at the root? I could see it exposed similar to how context is in setup(). I can't think of a way to achieve backwards compatibility with the current API. I also don't see how to access it since the function is used directly (imported and called) and there's no API on the outside. This makes me think that the API would have to exist on the inside of the function much like accessing a store is done:

export async function appendFile(file: File): Promise<void> {
    const store = useFilesStore();
    store.state.all.push(file);
}

Perhaps plugins have to be defined differently in order to be accessed here. All existing plugins would either define a new composition API or a dev could define their own composition wrapper on top of any that haven't converted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions