src/util/wait.js
/**
 * A promise that returns an EnabledElement who's image has loaded, or
 * null if the provided element ceases being an enabledElement before an
 * image has been loaded.
 * @public
 * @function waitForEnabledElementImageToLoad
 *
 * @param {HTMLElement} element - An element that is an EnabledElement
 * @returns {EnabledElement} - The enabled element that has loaded an image
 */
A promise that returns an EnabledElement who's image has loaded, or
null if the provided element ceases being an enabledElement before an
image has been loaded.

@param {HTMLElement} element - An element that is an EnabledElement
@returns {EnabledElement} - The enabled element that has loaded an image
A promise that returns an EnabledElement who ' s image has loaded or null if the provided element ceases being an enabledElement before an image has been loaded . @param { HTMLElement } element - An element that is an EnabledElement @returns { EnabledElement } - The enabled element that has loaded an image
function waitForEnabledElementImageToLoad(element) {
  try {
    const enabledElement = external.cornerstone.getEnabledElement(element);
    if (!enabledElement.image) {
      return wait(250).then(() => waitForEnabledElementImageToLoad(element));
    }
    return enabledElement;
  } catch (ex) {
    return null;
  }
}
function waitForEnabledElementImageToLoad ( element ) { try { const enabledElement = external . cornerstone . getEnabledElement ( element ) ; if ( ! enabledElement . image ) { return wait ( 250 ) . then ( ( ) => waitForEnabledElementImageToLoad ( element ) ) ; } return enabledElement ; } catch ( ex ) { return null ; } }
A promise that returns an EnabledElement who's image has loaded, or
 null if the provided element ceases being an enabledElement before an
 image has been loaded.
A promise that returns an EnabledElement who ' s image has loaded or null if the provided element ceases being an enabledElement before an image has been loaded .
// EnabledElement's image is loaded. // Is no longer, or never was an enabled element, stop polling