Skip to content
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

Add Vue 2 & 3 Plugins #407

Merged
merged 4 commits into from
Apr 16, 2021
Merged

Conversation

davidhemphill
Copy link
Contributor

This PR adds a little cute integration with Vue 2 and 3.

Usage:

// app.js

// Vue 2
import Vue from 'vue'
import { Vue2Plugin } from 'ziggy';

Vue.use(Vue2Plugin)

// Vue 3
import { createApp, h } from 'vue';
import { Vue3Plugin } from 'ziggy';
import App from './App'

createApp({
  render: () => h(App),
}).use(Vue3Plugin)

David Hemphill added 2 commits February 21, 2021 15:45
@bakerkretzmar
Copy link
Collaborator

Thanks! It looks to me like these plugins both require using the @routes directive, is that right?

@davidhemphill
Copy link
Contributor Author

Yeah, I believe so. :-)

@bakerkretzmar
Copy link
Collaborator

I really like this idea but I feel like people who need to customize their setup at all might still have to implement it manually so that they can pass in configuration.

For people using the @routes directive, this ends up being longer than just .mixin({ methods: { route } }), and people not using @routes would still have to import route and Ziggy and create the mixin manually so that they can pass the Ziggy object in.

It occurred to me that we could make the export a function that takes config arguments and builds the plugin object dynamically, but that's unconventional for Vue plugins.

What do you think?

@davidhemphill
Copy link
Contributor Author

I'm not married to it if you don't think it's a good idea. :-)

@bakerkretzmar
Copy link
Collaborator

Did some more research and realized: a) in this case we can use the same plugin for Vue 2 and 3, and b) you can pass options into a Vue plugin as the second argument to use(), which means the plugin can stay as a plain object and the extra config argument can be completely optional.

With those little added conveniences I'm super happy with this! Thanks for your patience! I'll tag a release this afternoon.

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

Successfully merging this pull request may close these issues.

2 participants