(condition: Function, interval = 100)
| 162 | } |
| 163 | |
| 164 | export function getAsyncWaitUntilTrue(condition: Function, interval = 100) { |
| 165 | let intervalId; |
| 166 | let rejectThis; |
| 167 | const reset = () => { |
| 168 | clearTimeout(intervalId); |
| 169 | if (rejectThis) rejectThis('AsyncWait stopped'); |
| 170 | }; |
| 171 | |
| 172 | return { |
| 173 | asyncWaitUntilTrue: () => { |
| 174 | reset(); |
| 175 | return new Promise<void>((resolve, reject) => { |
| 176 | rejectThis = reject; |
| 177 | intervalId = waitUntilTrue(condition, () => resolve(), interval); |
| 178 | }); |
| 179 | }, |
| 180 | reset, |
| 181 | }; |
| 182 | } |
| 183 | |
| 184 | const doubleId = Math.random(); |
| 185 | export function checkDoubleExecution() { |
no test coverage detected