I'm trying to do something bigpipe with koajs.
app.use(function* () {
this.type = 'html';
this.body = myPage.stream() // returns a readable
})
inside the myPage
myPage.prototype.stream = function() {
var readable = new stream.Readable();
readable._read = function() {};
co(myRender(readable.push.bind(readable))).catch(errorHandler)
return readable;
});
Then the render will do the rendering stuff (async);
However, it works smoothly until I tried to open multi tabs on my browser.
It will not render other pages until one is done (i had a setTimeout to simulate async stuff in the rendere).
Is there anyway to stream multiple connections simultaneously? Like it does with normal requests (not bigpipe) ?