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)
}))
Create an instance of the lazy route manager.
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.
Create a lazy route. The load
function can return a Promise or use the callback in its first parameter.
The lazy-route store emits the events listed below.
Emitted when a route starts loading. route
is a string.
Emitted when a route has loaded successfully. route
is a string. view
is the view function that was loaded.
- timeout
- loading view (show after 700ms or so)