UNPKG

@ledgerhq/live-common

Version:
18 lines 635 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runOnceWhen = runOnceWhen; function runOnceWhen(conditionFunc, callback, maxWaitTimeMS = 5000) { const interval = setInterval(() => { if (conditionFunc()) { clearInterval(interval); callback(); } }, 100); // Check every 100ms setTimeout(() => { // if the conditional function does not return // true after maxWaitTimeMS has passed then // clear the interval and stop checking. clearInterval(interval); }, maxWaitTimeMS); } //# sourceMappingURL=runOnceWhen.js.map