Skip to content

Instantly share code, notes, and snippets.

@bertoni
Last active June 29, 2018 14:31
Show Gist options
  • Save bertoni/22ee84b9edfc4580aa8dc2dc3d3dc316 to your computer and use it in GitHub Desktop.
Save bertoni/22ee84b9edfc4580aa8dc2dc3d3dc316 to your computer and use it in GitHub Desktop.
Vue-notification in the action VUEX
# src/vuex/actions.js
export default {
...
notify: (store, data) => {
Vue.prototype.$notify({
group: (data.group || 'general'),
type: (data.type || 'warn'),
duration: (data.time || 6000),
speed: (data.speed || 1000),
text: (data.text || ''),
title: (data.title || null)
})
},
...
}
# src/components/MyComponent.vue
<template>...</template>
<script>
export default {
name: 'MyComponent',
data () {
return {
...
}
}
methods: {
someMethod () {
...
this.$store.dispatch('notify', {text: 'Some message of success', type: 'success'})
...
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment