Skip to content

Instantly share code, notes, and snippets.

View M1cr0M1nd's full-sized avatar

Shlomo Michael Rubin M1cr0M1nd

  • ReasonLabs
  • Tel Aviv, Israel
View GitHub Profile
@M1cr0M1nd
M1cr0M1nd / 8.js
Last active May 29, 2019 11:04
Intro to the Vue State Manager - Vuex
import { mapGetters, mapActions } from 'vuex'
const store = new Vuex.Store({
state: {
score: 0
},
mutations: {
SET_SCORE (state, value) {
state.count += value
}
@M1cr0M1nd
M1cr0M1nd / 7.js
Created May 29, 2019 10:57
Intro to the Vue State Manager - Vuex
const app = new Vue({
el: '#app',
// provide the store using the "store" option.
// this will inject the store instance to all child components.
store,
components: { ScoreDashboard },
template: `
<div class="app">
<ScoreDashboard></ScoreDashboard>
</div>
@M1cr0M1nd
M1cr0M1nd / 6.js
Last active May 29, 2019 12:08
Intro to the Vue State Manager - Vuex
const ScoreDashboard = {
template: `<div>{{ score }}</div>`,
computed: {
score () {
return this.$store.state.score
}
},
mounted () {
this.$store.dispatch('setScore', 10)
}
@M1cr0M1nd
M1cr0M1nd / 5.js
Created May 29, 2019 10:56
Intro to the Vue State Manager - Vuex
const store = new Vuex.Store({
state: {
score: 0
},
mutations: {
SET_SCORE (state, value) {
state.score = value
}
},
actions: {
@M1cr0M1nd
M1cr0M1nd / 4.js
Created May 29, 2019 10:56
Intro to the Vue State Manager - Vuex
import Vue from 'vue'
import Vuex from 'vuex'
import Axios from 'axios' // For the example only
Vue.use(Vuex)
@M1cr0M1nd
M1cr0M1nd / 3.js
Created May 29, 2019 10:55
Intro to the Vue State Manager - Vuex
const store = new Vuex.Store({
state: {
score: 0
},
mutations: {
SET_SCORE (state, value) {
state.score = value
}
},
actions: {
@M1cr0M1nd
M1cr0M1nd / 2.js
Created May 29, 2019 10:52
Intro to the Vue State Manager - Vuex
const store = new Vuex.Store({
state: {
score: 0
},
mutations: {
SET_SCORE (state, value) {
state.score = value
}
}
})
@M1cr0M1nd
M1cr0M1nd / 1.js
Created May 29, 2019 10:51
Intro to the Vue State Manager - Vuex
const store = new Vuex.Store({
state: {
score: 0
}
})
const ScoreDashboard = {
template: `<div>{{ score }}</div>`,
computed: {
score () {