Merge pull request #10970 from Snuffleupagus/MessageHandler-simplify-finalize
Simplify, and inline, the `finalize` function in the `MessageHandler` class
This commit is contained in:
commit
766d076dcb
@ -60,10 +60,6 @@ function resolveOrReject(capability, data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function finalize(promise) {
|
|
||||||
return Promise.resolve(promise).catch(() => {});
|
|
||||||
}
|
|
||||||
|
|
||||||
function MessageHandler(sourceName, targetName, comObj) {
|
function MessageHandler(sourceName, targetName, comObj) {
|
||||||
this.sourceName = sourceName;
|
this.sourceName = sourceName;
|
||||||
this.targetName = targetName;
|
this.targetName = targetName;
|
||||||
@ -326,14 +322,14 @@ MessageHandler.prototype = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let deleteStreamController = () => {
|
let deleteStreamController = () => {
|
||||||
// Delete streamController only when start, pull and
|
// Delete the `streamController` only when the start, pull, and cancel
|
||||||
// cancel callbacks are resolved, to avoid "TypeError".
|
// capabilities have settled, to prevent `TypeError`s.
|
||||||
Promise.all([
|
Promise.all([
|
||||||
this.streamControllers[data.streamId].startCall,
|
this.streamControllers[data.streamId].startCall,
|
||||||
this.streamControllers[data.streamId].pullCall,
|
this.streamControllers[data.streamId].pullCall,
|
||||||
this.streamControllers[data.streamId].cancelCall
|
this.streamControllers[data.streamId].cancelCall
|
||||||
].map(function(capability) {
|
].map(function(capability) {
|
||||||
return capability && finalize(capability.promise);
|
return capability && capability.promise.catch(function() { });
|
||||||
})).then(() => {
|
})).then(() => {
|
||||||
delete this.streamControllers[data.streamId];
|
delete this.streamControllers[data.streamId];
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user