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

use from other plugin #75

Open
kermorgant opened this issue Jan 30, 2019 · 1 comment
Open

use from other plugin #75

kermorgant opened this issue Jan 30, 2019 · 1 comment

Comments

@kermorgant
Copy link

Hello,

In order to reduce coupling from external libs, I tried to wrap vue-snotify confirm action inside another plugin doing something like this

import Snotify, { SnotifyPosition } from 'vue-snotify'

export default {
    install (Vue, options) {
        Vue.prototype.$myConfirm = (message, callback) => {
            Vue.use(Snotify, {})
            Vue.$snotify.confirm('Confirm', '', {
                buttons: [
                    {
                        text: 'Oui',
                        action: (toast) => {
                            this.$snotify.remove(toast.id)
                            callback()
                        }
                    },
                    {text: 'Non', action: (toast) => this.$snotify.remove(toast.id)}
                ]
            })
        }
    }
}

but this would not work as Vue.$snotify is undefined. I've tried some other ways with the same result.

Is there a way to work around that issue ?

Thanks

@kermorgant
Copy link
Author

I noticed the typescript example which provided a way I could have followed here

Unfortunately, SnotifyService isn't exported anymore so that approach doesn't work.

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

No branches or pull requests

1 participant