0.1.1 • Published 6 years ago

choo-async v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

choo-async

Asynchronous rendering decorator for Choo.

Usage - Install - License: MIT

stability standard

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

License

MIT