Created
December 2, 2016 17:56
-
-
Save halan/cd9e74323870496591332feb4cffc52d to your computer and use it in GitHub Desktop.
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 { createStore } from 'redux' | |
const eevee = { especie: 'Eevee', level: 1 }; | |
const eeveelution = (state = eevee, action) => { | |
switch (action.type){ | |
case 'WATER_STONE': | |
return { ...state, specie: 'Vaporeon' }; | |
case 'THUNDER_STONE': | |
return { ...state, specie: 'Jolteon' }; | |
case 'FIRE_STONE': | |
return { ...state, specie: 'Flareon' }; | |
case 'LEVEL_UP': | |
return { ...state, level: state.level + 1}; | |
default: | |
return state; | |
} | |
} | |
const store = createStore(eeveelution); | |
store.subscribe(() => console.log(store.getState())); | |
console.log(store); | |
store.dispatch({ type: 'WATER_STONE' }); | |
store.dispatch({ type: 'LEVEL_UP' }); | |
store.dispatch({ type: 'THUNDER_STONE' }); | |
store.dispatch({ type: 'WATER_STONE' }); | |
console.log(eevee); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment