Bug 1495387 - introduce async front instantiation; r=ochameau

Depends on D8989

Differential Revision: https://phabricator.services.mozilla.com/D8990

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2018-10-18 14:34:33 +00:00
parent d440e92be8
commit 4448c52661

View File

@ -1604,7 +1604,13 @@ var FrontClassWithSpec = function(actorSpec, frontProto) {
// Existing Fronts are relying on the initialize instead of constructor methods.
const cls = function() {
const instance = Object.create(cls.prototype);
instance.initialize.apply(instance, arguments);
const initializer = instance.initialize.apply(instance, arguments);
// Async Initialization
// return a promise that resolves with the instance if the initializer is async
if (initializer && typeof initializer.then === "function") {
return initializer.then(resolve => instance);
}
return instance;
};
cls.prototype = extend(Front.prototype, generateRequestMethods(actorSpec, frontProto));