Skip to content

Init injections before state #5075

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
wants to merge 1 commit into from

Conversation

rayrutjes
Copy link
Contributor

This makes it possible to provide an injected value as the default for a prop

export default {
  inject: ['_searchStore'],
  props: {
    searchStore: {
      type: Object,
      default () {
        return this._searchStore
      }
    }
  }
}

That way the user can either explicitly pass the property, or otherwise we resolve it with the injected one.

From my understanding, initInjections doesn't really conflict with initState, is there a specific reason for having initState before initInjections?

This makes it possible to provide an injected value as the default for a prop
@kazupon
Copy link
Member

kazupon commented Mar 3, 2017

Thank you for your PR!

provide/inject feature improvement is discussioning in #5067 becase of some issues.
You can join to it. 😺

@znck znck mentioned this pull request Mar 3, 2017
@yyx990803
Copy link
Member

Thanks for the suggestions! Unfortunately simply moving the whole block would break the case where provide() rely on data/props. I implemented a proper change with tests in 16765db.

@yyx990803 yyx990803 closed this Mar 3, 2017
@rayrutjes
Copy link
Contributor Author

Arg, sorry about the noise, I naively looked at the code and read the tests expecting them to pass o_O

Thank you @kazupon for the link, I will definitely join the conversation, as this seems like a very promising feature that fills some gaps.

Thank you @yyx990803 for being so reactive and constructive, really appreciated!

@rayrutjes rayrutjes deleted the init-injections-before-state branch March 3, 2017 09:38
@rayrutjes
Copy link
Contributor Author

@yyx990803 do you have an idea about the ETA of the next release? I'm really looking forward to use the new implementation you came up with ;)

@yyx990803
Copy link
Member

@rayrutjes that may take a few days

@rayrutjes
Copy link
Contributor Author

That sounds great, using a local build of Vue in the meantime.
I can tell that the implementation you did is perfect for my use case.

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

Successfully merging this pull request may close these issues.

3 participants