READY/IN DEVELOPMENT/HOLD
YES | NO
A few sentences describing the overall goals of the pull request's commits.
version: 0.1 | |
phases: | |
install: | |
commands: | |
- printenv | |
- npm install | |
build: | |
commands: | |
- npm run build |
/* State Tree */ | |
{ | |
players: [{ | |
id: 1, | |
level: 10 | |
},{ | |
id: 2, | |
level: 20 | |
}] | |
} |
/* Action to be dispatched */ | |
{ | |
type: 'LEVEL_UP', | |
id: 1, | |
} |
const players = (state = [{ id: 1, level: 10 }], action) => { | |
if (action.type === 'LEVEL_UP') { | |
return state.map(player => { | |
if(player.id !== action.id) return state; | |
return { ...player, level: player.level + 1 } | |
}) | |
} else if (action.type === 'LEVEL_DOWN') { | |
return state.map(player => { | |
if(player.id !== action.id) return state; | |
return { ...player, level: player.level - 1 } |