choo-async
v0.1.1
Published
Asynchronous rendering decorator for Choo
Downloads
3
Readme
choo-async
Asynchronous rendering decorator for Choo.
Usage - Install - License: MIT
Usage
const choo = require('choo')
const async = require('choo-async')
const html = require('choo-async/html')
const app = async(choo())
app.route('/', async.catch(view, error))
app.mount('body')
async function view (state, emit) {
const lazyView = await import('./lazyView')
return html`
<body>
<h1>Hello</h1>
${lazyView(state, emit)}
</body>
`
}
function error (err) {
return (state, emit) => html`
<body>
<h2>An error has occured</h2>
<pre>${err.stack}</pre>
</body>
`
}
Install
npm install choo-async