Last active
August 29, 2015 14:25
-
-
Save yelouafi/30ac62e33f4be376af4f to your computer and use it in GitHub Desktop.
This file contains 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
const INC = Symbol('inc'); | |
const DEC = Symbol('dec'); | |
// model : Number | |
function view(count, handler) { | |
return h('div', [ | |
h('button', { | |
on : { click: handler.bind(null, {type: INC}) } | |
}, '+'), | |
h('button', { | |
on : { click: handler.bind(null, {type: DEC}) } | |
}, '-'), | |
h('div', `Count : ${count}`), | |
]); | |
} | |
function update(count, action) { | |
return action.type === INC ? count + 1 | |
: action.type === DEC ? count - 1 | |
: count; | |
} | |
export default { view, update, actions : { INC, DEC } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment