choo-lazy-route
lazy load choo routes from split bundles
Last updated 3 years ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install choo-lazy-route 
SYNC missed versions from official npm registry.

choo-lazy-route

var app = choo()
var splitRequire = require('split-require')
var lazyRoute = require('choo-lazy-route')()

app.use(lazyRoute)
app.route('/lazy-route', lazyRoute(function (cb) {
  splitRequire('./views/lazyView', cb)
}))

API

lazyRoute = require('choo-lazy-route')()

Create an instance of the lazy route manager.

app.use(lazyRoute)

Associate the lazy route manager with an app. The lazyRoute store also configures the app to take advantage of the experimental prefetch feature in bankai, so that server side rendering will include lazy routes.

app.route('/', lazyRoute(function load() {}))

Create a lazy route. The load function can return a Promise or use the callback in its first parameter.

Events

The lazy-route store emits the events listed below.

lazy-route:load(route)

Emitted when a route starts loading. route is a string.

lazy-route:loaded(route, view)

Emitted when a route has loaded successfully. route is a string. view is the view function that was loaded.

todo

  • timeout
  • loading view (show after 700ms or so)

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |