nandi95 / vue-toastify

🔥 Simple, extendable, dependency free notification plugin. 🔥
https://vue-toastify.netlify.com/
MIT License
227 stars 12 forks source link

Use vue-toastify from Vuex Store #14

Closed bhaskar-nair2 closed 4 years ago

bhaskar-nair2 commented 4 years ago

Hey, I was looking for a way to generate messages from my Vuex store. I have tried

Vue.$vToastify.error('easy-peasy');
this.$vToastify.error('easy-peasy');

both fail as vToastify is undefined in both..

Please note, I am using a dynamic store, which gets registered at runtime.

Thanks!

nandi95 commented 4 years ago

@bhaskar-nair2 This can be looked at, at some point in the future. Currently however, the priority is creating a decent documentation site. If you you're willing I accept PRs in the meantime.

bhaskar-nair2 commented 4 years ago

I understand.. Lemme see if I can do it..

nandi95 commented 4 years ago

@bhaskar-nair2 It seems you should ba able to access it like so: this._vm.$vToastify.success("called from store"); OR Vue.prototype.$vToastify.success("called from store");

nandi95 commented 4 years ago

Addressed in 1.8.0 You may now use it in vuex like:

import Vue from "vue";

const mutations = {
  updateValue(state, value) {
    state.value = value;
    Vue.$vToastify("Successfully updated value!");
    // OR
    this._vm.$vToastify("Successfully updated value!")
  }
};