Skip to content

Instantly share code, notes, and snippets.

@dmitry-vsl
Created November 15, 2017 16:34
Show Gist options
  • Save dmitry-vsl/8cd66a32d14134063d1957cbec1566ad to your computer and use it in GitHub Desktop.
Save dmitry-vsl/8cd66a32d14134063d1957cbec1566ad to your computer and use it in GitHub Desktop.
function CounterView(data, handlers){
return div(null,
button({onClick: handlers.inc},
'Inc'
)
button({onClick: handlers.decAsync},
'Dec async'
),
span(null,
'Count: ', data.counter
)
)
}
var CounterHandlers = {
getInitialState(){
return 0
},
inc(state){
return state + 1
},
decAsync(state){
return Promise.resolve(state - 1)
},
}
var Counter = Component(CounterView, CounterHandlers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment