Files
spore-ui/public/scripts/components/ComponentsLoader.js

16 lines
760 B
JavaScript

(function(){
// Simple readiness flag once all component constructors are present
function allReady(){
return !!(window.PrimaryNodeComponent && window.ClusterMembersComponent && window.NodeDetailsComponent && window.FirmwareComponent && window.ClusterViewComponent && window.FirmwareViewComponent && window.TopologyGraphComponent && window.MemberCardOverlayComponent && window.ClusterStatusComponent);
}
window.waitForComponentsReady = function(timeoutMs = 5000){
return new Promise((resolve, reject) => {
const start = Date.now();
(function check(){
if (allReady()) return resolve(true);
if (Date.now() - start > timeoutMs) return reject(new Error('Components did not load in time'));
setTimeout(check, 25);
})();
});
};
})();