Skip to content

Conversation

@eddow
Copy link
Contributor

@eddow eddow commented Feb 1, 2019

In order to let the user initialize its data knowing the vm

@HerringtonDarkholme
Copy link
Member

May I ask the use case here? data function can usually access props. Do this change intend to access prototype method on vm?

@eddow
Copy link
Contributor Author

eddow commented Feb 2, 2019

Well, in my library here, who is a layout management, the layout elements need to access the layout manager - this one container that would have to be provided by the ancestor and injected in the elements.

If there was another way already existing, I would be more than happy to learn about it - how are props accessed from the data function - and more over, does it go through the constructor ?

@ktsn
Copy link
Member

ktsn commented Feb 7, 2019

Well, if the provided object is not injected into this in constructor, we should port them too.
In any cases, you should use lifecycle hooks like beforeCreate instead of constructor when you want actual vm.

@eddow
Copy link
Contributor Author

eddow commented Feb 7, 2019

Thank you for the beforeCreate : it will do the job, the PR is useless.
If someone wonder, I found even another solution (using vue-class-component)

@Provide() get layout() { return this; }

Basically, to provide a computed property.

@eddow eddow closed this Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants