mirror of https://github.com/grpc/grpc-web.git
Merge pull request #114 from stanley-cheung/master
Expose stream end event to client
This commit is contained in:
commit
19e37d1794
|
|
@ -67,6 +67,13 @@ grpc.web.ClientReadableStream = function(
|
||||||
*/
|
*/
|
||||||
this.onStatusCallback_ = null;
|
this.onStatusCallback_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {function(...):?|null}
|
||||||
|
* The stream end callback
|
||||||
|
*/
|
||||||
|
this.onEndCallback_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {function(?):!grpc.web.Status}
|
* @type {function(?):!grpc.web.Status}
|
||||||
|
|
@ -87,6 +94,11 @@ grpc.web.ClientReadableStream = function(
|
||||||
self.onStatusCallback_(status);
|
self.onStatusCallback_(status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.xhrNodeReadableStream_.on('end', function() {
|
||||||
|
if (self.onEndCallback_) {
|
||||||
|
self.onEndCallback_();
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -105,6 +117,8 @@ grpc.web.ClientReadableStream.prototype.on = function(
|
||||||
this.onDataCallback_ = callback;
|
this.onDataCallback_ = callback;
|
||||||
} else if (eventType == 'status') {
|
} else if (eventType == 'status') {
|
||||||
this.onStatusCallback_ = callback;
|
this.onStatusCallback_ = callback;
|
||||||
|
} else if (eventType == 'end') {
|
||||||
|
this.onEndCallback_ = callback;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue