File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1- var split = require ( 'split-require' )
1+ // var split = require('split-require')
22var css = require ( 'sheetify' )
33var choo = require ( '../' )
4+ var html = require ( 'choo/html' )
45
56css ( 'todomvc-common/base.css' )
67css ( 'todomvc-app-css/index.css' )
@@ -16,6 +17,12 @@ app.route('#active', require('./views/main'))
1617app . route ( '#completed' , require ( './views/main' ) )
1718app . route ( '*' , require ( './views/main' ) )
1819
19- app . experimentalAsyncRoute ( '/async' , ( ) => split ( './views/main.js' ) )
20+ app . experimentalAsyncRoute ( '/async' , ( ) => Promise . resolve ( function ( state , emit ) {
21+ return html `
22+ < body >
23+ Async rendering.
24+ </ body >
25+ `
26+ } ) )
2027
2128module . exports = app . mount ( 'body' )
Original file line number Diff line number Diff line change @@ -83,9 +83,9 @@ Choo.prototype.route = function (route, handler) {
8383}
8484
8585// Register a route to be loaded asynchronously.
86- Choo . prototype . experimentalAsyncRoute = function ( route , load ) {
86+ Choo . prototype . experimentalAsyncRoute = function ( route , loader ) {
8787 assert . equal ( typeof route , 'string' , 'choo.asyncRoute: asyncRoute should be type string' )
88- assert . equal ( typeof handler , 'function' , 'choo.asyncRoute: route should be type function' )
88+ assert . equal ( typeof loader , 'function' , 'choo.asyncRoute: loader should be type function' )
8989
9090 var IDLE = 0
9191 var LOADING = 1
@@ -104,7 +104,7 @@ Choo.prototype.experimentalAsyncRoute = function (route, load) {
104104 renderRoute = state . route
105105 loadingState = LOADING
106106
107- var p = load ( onload )
107+ var p = loader ( onload )
108108 assert ( p && p . then , 'choo.asyncRoute: async route should return a Promise' )
109109 p . then ( onload . bind ( null , null ) , onload )
110110 return self . _asyncProxy
You can’t perform that action at this time.
0 commit comments