项目作者: nearform

项目描述 :
Asynchronous rendering decorator for Choo
高级语言: JavaScript
项目地址: git://github.com/nearform/choo-async.git
创建时间: 2018-04-09T10:52:08Z
项目社区:https://github.com/nearform/choo-async

开源协议:

下载


choo-async

Asynchronous rendering decorator for Choo.

Usage -
Install -
License: MIT

stability
standard

Usage

  1. const choo = require('choo')
  2. const async = require('choo-async')
  3. const html = require('choo-async/html')
  4. const app = async(choo())
  5. app.route('/', async.catch(view, error))
  6. app.mount('body')
  7. async function view (state, emit) {
  8. const lazyView = await import('./lazyView')
  9. return html`
  10. <body>
  11. <h1>Hello</h1>
  12. ${lazyView(state, emit)}
  13. </body>
  14. `
  15. }
  16. function error (err) {
  17. return (state, emit) => html`
  18. <body>
  19. <h2>An error has occured</h2>
  20. <pre>${err.stack}</pre>
  21. </body>
  22. `
  23. }

Install

  1. npm install choo-async

License

MIT