Created
November 15, 2017 16:34
-
-
Save dmitry-vsl/8cd66a32d14134063d1957cbec1566ad 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
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