Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,43 @@ export default {
<style src="vue-notifyjs/themes/default.css"></style>

```

## 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: '<App/>',
components: { App }
})

```
Now you can dispatch an action like so
```javascript
this.$store.dispatch('notify', {
message: 'Welcome!',
type: 'success',
});
```
**Note:** `<notifications></notifications>` can be declared only once anywhere in your app,
preferably in your root component so the notification component is alive inside any other components.

Expand Down