UNPKG

react-imported-component

Version:
29 lines (28 loc) 632 B
/** * pending indicates any ongoing procceses */ let pending = []; export const addPending = (promise) => { pending.push(promise); }; export const removeFromPending = (promise) => { pending = pending.filter((a) => a !== promise); }; /** * is it really ready? */ let readyFlag = false; export const isItReady = () => readyFlag; /** * waits for all necessary imports to be fulfilled */ export const done = () => { if (pending.length) { readyFlag = false; return Promise.all(pending) .then((a) => a[1]) .then(done); } readyFlag = true; return Promise.resolve(); };