choo-detached
v1.0.1
Published
Detached (routerless) choo solution
Downloads
2
Maintainers
Readme
choo-detached
A wrapper around choo API that allows to use choo components without a baked-in routing layer.
Example
var choo = require('choo-detached')
var html = require('choo-detached/html')
var log = require('choo-log')
var app = choo()
app.use(log())
app.use(countStore)
app.component(mainView)
app.mount('body')
function mainView (state, emit) {
return html`
<body>
<h1>count is ${state.count}</h1>
<button onclick=${onclick}>Increment</button>
</body>
`
function onclick () {
emit('increment', 1)
}
}
function countStore (state, emitter) {
state.count = 0
emitter.on('increment', function (count) {
state.count += count
emitter.emit('render')
})
}