Skip to content

Instantly share code, notes, and snippets.

@TheDutchCoder
Created January 18, 2017 16:51
Show Gist options
  • Save TheDutchCoder/ba27e46c996a1509b5c88fbb1f1e9201 to your computer and use it in GitHub Desktop.
Save TheDutchCoder/ba27e46c996a1509b5c88fbb1f1e9201 to your computer and use it in GitHub Desktop.
// Types.
import {
NOTIFICATIONS_ADD,
NOTIFICATIONS_REMOVE
} from '../mutation-types'
// Default state.
const state = {
items: []
}
// Mutations.
const mutations = {
[NOTIFICATIONS_ADD] (state, notification) {
state.items.push(notification)
},
[NOTIFICATIONS_REMOVE] (state, index) {
state.items = [
...state.items.slice(0, index),
...state.items.slice(index + 1)
]
}
}
// Export.
export default {
state,
mutations
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment