vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
208k stars 33.69k forks source link

State of provide/inject #5067

Closed znck closed 7 years ago

znck commented 7 years ago

Provide/Inject allows ancestor component to serve as a dependency injector. Injected dependencies are not reactive. As per docs, if an observed property is provided it remains reactive.

I've created a fiddle (https://jsfiddle.net/1hcpbrjz/6/) to demonstrate few scenarios.

This feature is very new, so docs are too shallow.

Question: How to provide reactive data props and computed prop?

Update: 3rd March

( #5075 ) Initialising injections before state would allow using injections in props. https://jsfiddle.net/fsurfc5w/

Akryum commented 7 years ago

Provide an object with reactive data inside.

znck commented 7 years ago

@Akryum Can you update the fiddle with an example?

I think we should add some examples in docs too.

lifedever commented 7 years ago

https://github.com/vuejs/vue/pull/5075

lifedever commented 7 years ago

https://github.com/vuejs/vue/pull/5229