|  |  |  | @ -15,10 +15,35 @@ export default new Vuex.Store({ | 
		
	
		
			
				|  |  |  |  |   getters: { | 
		
	
		
			
				|  |  |  |  |     countLinks: state => { return state.links.length } | 
		
	
		
			
				|  |  |  |  |   }, | 
		
	
		
			
				|  |  |  |  |   // Used when we want to change state data
 | 
		
	
		
			
				|  |  |  |  |   // Should be used for synchronous functions
 | 
		
	
		
			
				|  |  |  |  |   mutations: { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // By convention mutators are all caps
 | 
		
	
		
			
				|  |  |  |  |     ADD_LINK: (state, link) => { | 
		
	
		
			
				|  |  |  |  |       state.links.push(link) | 
		
	
		
			
				|  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |     REMOVE_LINK: (state, link) => { | 
		
	
		
			
				|  |  |  |  |       state.links.splice(link, 1) | 
		
	
		
			
				|  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |     REMOVE_ALL: (state) => { | 
		
	
		
			
				|  |  |  |  |       state.links = [] | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   }, | 
		
	
		
			
				|  |  |  |  |   // Actions are for async functions
 | 
		
	
		
			
				|  |  |  |  |   actions: { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // the context provides you the same methods and instances as the store instance, and then we pass in a payload
 | 
		
	
		
			
				|  |  |  |  |     // Here we are using actions to asynchronously call a mutation function
 | 
		
	
		
			
				|  |  |  |  |     removeLink(context, link) { | 
		
	
		
			
				|  |  |  |  |       context.commit("REMOVE_LINK", link) | 
		
	
		
			
				|  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |     // Pretty sure we are just using object destructuring here
 | 
		
	
		
			
				|  |  |  |  |     removeAll({commit}) { | 
		
	
		
			
				|  |  |  |  |       return new Promise((resolve, reject) => { | 
		
	
		
			
				|  |  |  |  |         setTimeout(()=> { | 
		
	
		
			
				|  |  |  |  |           commit('REMOVE_ALL') | 
		
	
		
			
				|  |  |  |  |           resolve() | 
		
	
		
			
				|  |  |  |  |         }, 1500) // 1.5 seconds
 | 
		
	
		
			
				|  |  |  |  |       }) | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | }) | 
		
	
	
		
			
				
					|  |  |  | 
 |