Skip to content

Commit

Permalink
Added flush calls to renderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
aickin committed Oct 22, 2015
1 parent 4c451c9 commit e538e62
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/renderers/dom/server/ReactServerAsyncRendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ var instantiateReactComponent = require('instantiateReactComponent');
var invariant = require('invariant');
var rollingAdler32 = require('rollingAdler32');

function bufferedStream(stream) {
function bufferedStream(stream, bufferSize) {
// for now, we need to buffer some of the stream coming out; express performs really poorly if you
// chunk out a few bytes at a time. I plan to move this functionality into react-dom-stream.
return {
write: function(data, bufferSize) {
write: function(data) {
this.buffer = this.buffer || "";
this.buffer += data;

if (this.buffer.length >= bufferSize) {
this.writeCount = this.writeCount ? this.writeCount + 1 : 1;
stream.write(this.buffer);
stream.flush();
this.buffer = "";
}
},

flush: function() {
stream.write(this.buffer);
stream.flush();
},

end: function(data) {
stream.write(this.buffer);
console.log("Write Count: " + (this.writeCount + 1));
stream.flush();
stream.end(data);
}
}
Expand Down

0 comments on commit e538e62

Please sign in to comment.