-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Added a cookbook on how to make a useful Vue plugin #2422
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
base: master
Are you sure you want to change the base?
Added a cookbook on how to make a useful Vue plugin #2422
Conversation
@sdras Hey 👋 Just wanted to nudge you on this PR 😸 |
@sdras Hey, any luck on this PR? 😊 |
Sorry about that! Will take a look this weekend! |
@sdras No stress :) Thanks for the help |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a wonderful addition! The only major thing missing is a real-life example. The tone and pace are great, though, I think that's pretty much the only thing missing :)
|
||
## Base Example | ||
|
||
Vue exposes a really nifty API for creating plugins, plugins allow us to modify and add features to Vue. This cookbook is aimed at showing you how to take a simple idea and turn it into a full-fledged Vue plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice intro :)
The idea could be carried through the sentence to be a little more clear:
Vue exposes a really nifty API for creating plugins, which allow us to modify and add features.
import Vue from 'vue' | ||
|
||
const plugin = { | ||
install(LocalVue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth a comment here or sentence above to explain what LocalVue
is because it's probably difficult for them to infer at this point.
install(LocalVue) { | ||
LocalVue.mixin({ | ||
beforeCreate() { | ||
this // we can access the component instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice addition, sometimes people don't know you can access this
here
|
||
#### Step 3 - Map vuex | ||
|
||
```js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is all good, but there's no real use case you're covering here. Without a real use case, it's tough for the reader to understand how this is useful. I like what you have- no need to change that, but we do ask for an actual example to bring the cookbook to life and out of just a conceptual model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool thanks, so you mean a demo of something correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have a really good real-world use case that I can add to the cookbook, I will update it :)
}).$mount('#app') | ||
``` | ||
|
||
## Creating a NPM package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great :)
@sdras Thanks for the review, I appreciate the feedback 😄 Do you have an example of a real-world use case for the Plugin API, so I can get an idea of what would be the best fit for the cookbook |
@sdras In the cookbook, would it be possible to reference myself or my team as in Me and We? I am busy adding a real-world example where my team and I created a plugin to share across all of our Vue-based projects |
@sdras Hope you are well, I spent some time adding a real-world example. I hope you think it brings this cookbook to life. Do you mind taking another look, please? 🙏 Here is a link to the real-world example |
@sdras Hey, just a slight nudge on this one. Sorry to disturb 🙏 |
This PR contains a cookbook on how to make a Vue plugin which aims to demystify some of the concepts as well as make it more approachable to developers who are just starting to get into the Vue open-source ecosystem.