Created
          July 24, 2019 12:19 
        
      - 
      
 - 
        
Save harrybeckwith/54afd2e8afb510741efad98a5fd2bb2d to your computer and use it in GitHub Desktop.  
    mutations and actions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import Vue from 'vue'; | |
| import Vuex from 'vuex'; | |
| Vue.use(Vuex); | |
| export const store = new Vuex.Store({ | |
| state: { | |
| categories: ['travel', 'fun', 'social', 'work', 'other'], | |
| events: [], | |
| }, | |
| getters: { | |
| cat: state => { | |
| return state.categories; | |
| }, | |
| getEventById: state => id => { | |
| return state.events.find(event => event.id === id); | |
| }, | |
| events: state => { | |
| return state.events; | |
| }, | |
| }, | |
| mutations: { | |
| ADD_EVENT(state, event) { | |
| state.events.push(event); | |
| }, | |
| }, | |
| actions: { | |
| createEvent({ commit }, event) { | |
| commit('ADD_EVENT', event); | |
| }, | |
| }, | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment