Last active
November 23, 2017 20:11
-
-
Save jongacnik/84fd53fc0ea53240da89bef9573c9644 to your computer and use it in GitHub Desktop.
choop - jsx
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
/** @jsx h */ | |
var devtools = require('choo-devtools') | |
var choop = require('choop') | |
var h = require('choop/h') | |
var app = choop() | |
app.use(devtools()) | |
app.use(countStore) | |
app.route('*', mainView) | |
app.mount('body') | |
function mainView (state, emit) { | |
return <main> | |
<h1>count is {state.count}</h1> | |
<button onclick={onclick}>Increment</button> | |
</main> | |
function onclick () { | |
emit('increment', 1) | |
} | |
} | |
function countStore (state, emitter) { | |
state.count = 0 | |
emitter.on('increment', function (count) { | |
state.count += count | |
emitter.emit('render') | |
}) | |
} |
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
{ | |
"dependencies": { | |
"choo-devtools": "2.2.0", | |
"choop": "3.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment