vue-snotify icon indicating copy to clipboard operation
vue-snotify copied to clipboard

VueJS - VueX and flash messages

Open pirmax opened this issue 6 years ago • 3 comments

I use VueJS 2, VueX, NuxtJS and Vue-Snotify for flash notifications.

It may not be the correct use of VueX, but I'd like to dispatch the errors caught in a try/catch.

try {
	throw new Error('test')
} catch (error) {
	this.$store.dispatch('errorHandler', error)
}

Then the dispatch, with VueX should display the notifications with Snotify-View with a loop if there are several errors.

actions: {
    async errorHandler (error) {
    	this.$snotify.error(error)
    	// and if multiple errors, then while on error
    }
}

What do you think and how to recover the instance of $snotify in VueX?

pirmax avatar May 07 '18 13:05 pirmax

It would be great if we can use notifications how it realized in element ui for example:

import { Message } from 'element-ui'; actions: { showSuccessMessage (options) { Message.success(options) } }

2vsl avatar May 14 '18 05:05 2vsl

Have you tried accessing $snotify directly from Vue? It's a little hacky but should work.

actions: {
    async errorHandler (error) {
    	Vue.prototype.$snotify.error(error)
    	// and if multiple errors, then while on error
    }
}

knackjason avatar Nov 14 '18 17:11 knackjason

Hi! I don't know if you still need help, you've probably already solved it, but this might help somebody: this._vm.$snotify.error(error)

Originally posted by @serkandemirel0420 in https://github.com/vuejs/vuex/issues/1399#issuecomment-449972993

JoaoPedroAS51 avatar Feb 26 '19 17:02 JoaoPedroAS51