diff --git a/README.md b/README.md index c0100a3..fff656b 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,43 @@ export default { ``` + +## With Vuex +```javascript +import Vue from 'vue' +import App from './App' +import Notify from 'vue-notifyjs'; +import Vuex from "vuex" + +Vue.use(Notify) +Vue.use(Vuex) + +let notifier = new Vue() + +const store = new Vuex.Store({ + state:{}, + actions:{ + notify(context, payload){ + notifier.$notify(payload) + } + } +}) + +new Vue({ + el: '#app', + store, + template: '', + components: { App } +}) + +``` +Now you can dispatch an action like so +```javascript +this.$store.dispatch('notify', { + message: 'Welcome!', + type: 'success', + }); +``` **Note:** `` can be declared only once anywhere in your app, preferably in your root component so the notification component is alive inside any other components.