Skip to content

API Reference missing app.provide method #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
skirtles-code opened this issue Aug 14, 2020 · 4 comments
Closed

API Reference missing app.provide method #406

skirtles-code opened this issue Aug 14, 2020 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@skirtles-code
Copy link
Contributor

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.
@NataliaTepluhina NataliaTepluhina self-assigned this Aug 14, 2020
@NataliaTepluhina
Copy link
Member

NataliaTepluhina commented Aug 14, 2020

@skirtles-code thank you for the issue and for the amazingly detailed description! Would you prefer to create a PR for this or to leave this for me? Either way is fine 👍🏻

@skirtles-code
Copy link
Contributor Author

@NataliaTepluhina I'd be happy to give it a go.

@NataliaTepluhina
Copy link
Member

@skirtles-code awesome! Looking forward to a PR then 👍🏻

@NataliaTepluhina
Copy link
Member

Closing an issue as related PR was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants