yog-bigpipe
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -11,3 +11,3 @@ var BigPipe = require('./lib/bigpipe.js'); | ||
res.removeListener('finish', destroy); | ||
res.removeListener('close', destroy); | ||
//res.removeListener('close', destroy); | ||
@@ -26,3 +26,3 @@ bigpipe.destroy(); | ||
res.on('finish', destroy); | ||
res.on('close', destroy); | ||
//res.on('close', destroy); | ||
@@ -29,0 +29,0 @@ next(); |
@@ -27,2 +27,4 @@ var Pagelet = require('./pagelet.js'); | ||
BigPipe.options = { | ||
// configure output template. | ||
tpl: { | ||
@@ -52,2 +54,6 @@ _default: '<script type="text/javascript">BigPipe.onPageletArrive(${data});</script>', | ||
if (this.state === status.fulfilled) { | ||
return false; | ||
} | ||
// todo 如果 quickling 的 widget 藏在某些异步 widget 里面,岂不是找不到? | ||
@@ -75,3 +81,3 @@ if (!this.isQuickingMode() && obj.mode !== mode.pipeline && obj.mode !== mode.async) { | ||
pagelet.on('ready', this._onPageletReady.bind(this)); | ||
pagelet.once('ready', this._onPageletReady.bind(this)); | ||
@@ -135,4 +141,9 @@ if (this.state === status.rendering) { | ||
process.nextTick(this._checkFinish.bind(this)); | ||
}; | ||
BigPipe.prototype._checkFinish = function() { | ||
if (!this.pagelets.length) { | ||
cb = this.cb; | ||
// 标记已经完成。 | ||
@@ -139,0 +150,0 @@ this.state = status.fulfilled; |
@@ -5,2 +5,4 @@ var util = require("util"); | ||
var Pagelet = module.exports = function Pagelet(obj) { | ||
this.model = obj.model; | ||
this.alias = obj['for']; | ||
this.mode = obj.mode; | ||
@@ -55,3 +57,3 @@ this.id = obj.id; | ||
} else { | ||
process.nextTick(this._render.bind(this)); | ||
this._render(); | ||
} | ||
@@ -79,2 +81,3 @@ }; | ||
}); | ||
locals._yog.addPagelet = origin; | ||
locals = self = origin = null; | ||
@@ -122,4 +125,4 @@ }; | ||
this.state = status.fulfilled; | ||
this.emit('ready', this); | ||
this.onReady && this.onReady(); | ||
this.emit('ready', this); | ||
}; | ||
@@ -129,2 +132,3 @@ | ||
return { | ||
container: this.alias || '', | ||
id: this.id, | ||
@@ -142,4 +146,4 @@ html: this.html, | ||
this.removeAllListeners(); | ||
this.fis = this.mode = this.id = this.locals = this.compiled = this.state = this.html = null; | ||
this._yog = this.mode = this.id = this.locals = this.compiled = this.state = this.html = null; | ||
this.scripts = this.js = this.css = this.styles = null; | ||
} |
{ | ||
"name": "yog-bigpipe", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "An express.js middleware for fis widget pipline output.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -170,3 +170,6 @@ (function() { | ||
dom = data.container || document.getElementById(data.id); | ||
dom = data.container && typeof data.container === 'string' ? | ||
document.getElementById(data.container) : | ||
(data.container || document.getElementById(data.id)); | ||
dom.innerHTML = data.html; | ||
@@ -173,0 +176,0 @@ |
21880
555