UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

30 lines (29 loc) 829 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.waitForCondition = void 0; const waitForCondition = (isReady, timeout = 5000) => { const startTime = Date.now(); const ready = isReady(); if (ready) { return Promise.resolve(); } return new Promise((resolve, reject) => { const wait = (callback) => { const ready = isReady(); if (Date.now() - startTime > timeout) { reject('Wait time expired'); return; } if (!ready) { setTimeout(() => { wait(callback); }, 16); } else { callback(); } }; wait(resolve); }); }; exports.waitForCondition = waitForCondition;