UNPKG

comindware.core.ui

Version:

Comindware Core UI provides the basic components like editors, lists, dropdowns, popups that we so desperately need while creating Marionette-based single-page applications.

19 lines (18 loc) 761 B
export default class TestService { static wait({ action, condition, callback, checkInterval = 0, repeatAction = false } = {}) { return new Promise(resolve => { let isActionCalled = false; const shouldCallAction = () => repeatAction || !isActionCalled; const first = setInterval(() => { if (typeof action === 'function' && shouldCallAction()) { isActionCalled = true; action(); } if (typeof condition === 'function' ? condition() : true) { clearInterval(first); resolve(typeof callback === 'function' && callback()); } }, checkInterval); }); } }