Skip to content

API Reference missing app.provide method #406

Closed
@skirtles-code

Description

@skirtles-code

The method app.provide is not documented in the API Reference.

There is a mention of it here but the example is incorrect:

https://github.com/vuejs/docs-next/blame/639940b6154e318b0b26fd4a394defaa82eb45ba/src/guide/migration/global-api.md#L168

The current example given is:

app.provide({
  guide: 'Vue 3 Guide'
})

I believe that should be:

app.provide('guide', 'Vue 3 Guide')

A few lines later from: guide also needs changing to from: 'guide'.

There is an important distinction between the provide method, which is part of the Application API, and the provide option for components. While they're both part of the provide/inject mechanism they are distinct ways to provide data.

I've put together an example to demonstrate the difference between the two:

https://jsfiddle.net/skirtle/59h2ya1g/3/

I'm not suggesting using that example in the documentation as I suspect it would be confusing. I just wanted to illustrate the difference between the two here. Notice how data provided via the application is injected into the root component, whereas data provided by the root component is only available in its descendants, not in the root component itself.

I reported these problems previously (#345) but I think there may have been a misunderstanding about what changes needed to be made. In summary:

  1. The provide method needs to be documented in the Application API section of the API Reference.
  2. The example in the migration guide needs to be updated.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions