Skip to content

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

shailen-naidoo
Copy link

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.

@shailen-naidoo shailen-naidoo changed the title Added a cookbook on how to make a useful Vue plugin WIP: Added a cookbook on how to make a useful Vue plugin Dec 23, 2019
@shailen-naidoo shailen-naidoo changed the title WIP: Added a cookbook on how to make a useful Vue plugin Added a cookbook on how to make a useful Vue plugin Dec 23, 2019
@shailen-naidoo
Copy link
Author

@sdras Hey 👋 Just wanted to nudge you on this PR 😸

@shailen-naidoo
Copy link
Author

@sdras Hey, any luck on this PR? 😊

@sdras
Copy link
Member

sdras commented Mar 21, 2020

Sorry about that! Will take a look this weekend!

@shailen-naidoo
Copy link
Author

@sdras No stress :) Thanks for the help

Copy link
Member

@sdras sdras left a 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.
Copy link
Member

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) {
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.

Copy link
Author

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?

Copy link
Author

@shailen-naidoo shailen-naidoo Mar 23, 2020

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great :)

@shailen-naidoo
Copy link
Author

@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

@shailen-naidoo
Copy link
Author

@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

@shailen-naidoo shailen-naidoo requested a review from sdras March 30, 2020 18:46
@shailen-naidoo
Copy link
Author

@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

@shailen-naidoo
Copy link
Author

@sdras Hey, just a slight nudge on this one. Sorry to disturb 🙏

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

Successfully merging this pull request may close these issues.

4 participants