react-imported-component
Version:
I will import your component, and help to handle it
36 lines (35 loc) • 977 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.done = exports.isItReady = exports.removeFromPending = exports.addPending = void 0;
/**
* pending indicates any ongoing procceses
*/
var pending = [];
var addPending = function (promise) {
pending.push(promise);
};
exports.addPending = addPending;
var removeFromPending = function (promise) {
pending = pending.filter(function (a) { return a !== promise; });
};
exports.removeFromPending = removeFromPending;
/**
* is it really ready?
*/
var readyFlag = false;
var isItReady = function () { return readyFlag; };
exports.isItReady = isItReady;
/**
* waits for all necessary imports to be fulfilled
*/
var done = function () {
if (pending.length) {
readyFlag = false;
return Promise.all(pending)
.then(function (a) { return a[1]; })
.then(exports.done);
}
readyFlag = true;
return Promise.resolve();
};
exports.done = done;
;