1

我正在尝试用 koajs 做一些大管道。

app.use(function* () {
    this.type = 'html';
    this.body = myPage.stream() // returns a readable
})

在 myPage 里面

myPage.prototype.stream = function() {
    var readable = new stream.Readable();
    readable._read = function() {};
    co(myRender(readable.push.bind(readable))).catch(errorHandler)
    return readable;
});

然后渲染将做渲染的东西(异步);

但是,在我尝试在浏览器上打开多个标签之前,它运行顺利。

在完成之前它不会渲染其他页面(我有一个 setTimeout 来模拟渲染中的异步内容)。

无论如何要同时流式传输多个连接吗?就像普通请求(不是 bigpipe)一样?

4

0 回答 0