euvl / vue-notification

:icecream: Vue.js 2 library for showing notifications
http://vue-notification.yev.io/
MIT License
2.39k stars 213 forks source link

Invoke notifications from vux store #221

Closed Vidhyanandcs closed 3 years ago

Vidhyanandcs commented 3 years ago

I was looking for a notification that can be invoked from vuex store I have an action which will be triggered when an error happens. i would like to invoke notifications in this action.

Currently using bootstrap vue import { BToast } from 'bootstrap-vue' let bootStrapToaster = new BToast(); bootStrapToaster.$bvToast.toast(error.response.data.message, { variant: 'danger', headerClass: ['red-toast'], id: 'red-toast' })

daverogers commented 3 years ago

I'm using Vue CLI so it's probably a bit different, but maybe this will help

// boot.js
import Notifications from 'vue-notification'

Vue.use(Notifications)

// Vuex action
.catch((error) => {
    this._vm.$notify({
        type: 'error',
        title: 'Error Saving New Mapping',
        text: error.response.data.error
    })
    reject(error.response.data.error)
})
github-actions[bot] commented 3 years ago

Stale issue message