Skip to content

Instantly share code, notes, and snippets.

@yelouafi
Last active August 29, 2015 14:25
Show Gist options
  • Save yelouafi/30ac62e33f4be376af4f to your computer and use it in GitHub Desktop.
Save yelouafi/30ac62e33f4be376af4f to your computer and use it in GitHub Desktop.
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