Comparing version 0.6.0 to 0.7.0
24
index.js
@@ -32,19 +32,21 @@ 'use strict'; | ||
var prototols = layer(res, settings); | ||
var preFetch = []; | ||
if (prototols.bigpipe && prototols.bigpipe.isQuicklingMode() === false) { | ||
// 准备页面数据 | ||
preFetch.push(prototols.bigpipe.preparePageOnly().then(function (data) { | ||
// 页面数据应与locals合并 | ||
if (data) { | ||
_.mixin(locals, data); | ||
} | ||
})); | ||
} | ||
if (prototols.bigpipe && prototols.bigpipe.isSpiderMode) { | ||
// 获取所有异步pagelet信息 | ||
prototols.bigpipe.prepareAllSources().then(function (data) { | ||
render(); | ||
}).catch(function (err) { | ||
// prepareAllSources 不会因为数据准备异常而触发异常,而是错误的 bind 才会引发异常,比如没有返回一个 Promise | ||
done(err); | ||
}); | ||
preFetch.push(prototols.bigpipe.prepareAllSources()); | ||
} | ||
else { | ||
render(); | ||
} | ||
Promise.all(preFetch).then(render).catch(done); | ||
function render() { | ||
var sentData = false; | ||
me.engine.makeStream(filepath, _.mixin(locals, { | ||
@@ -51,0 +53,0 @@ _yog: prototols |
{ | ||
"name": "yog-view", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "An express.js middleware for optimizing the order of js\\css output, and enabling render template in bigpipe mode.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
24440
625