| 124 | } |
| 125 | |
| 126 | export function changeDetect(callback, func, immediate = false) { |
| 127 | let currentPage = func(); |
| 128 | const intervalId = setInterval(function () { |
| 129 | const temp = func(); |
| 130 | if (typeof temp !== 'undefined' && currentPage !== temp) { |
| 131 | currentPage = func(); |
| 132 | callback(); |
| 133 | } |
| 134 | }, 500); |
| 135 | |
| 136 | if (immediate) callback(); |
| 137 | |
| 138 | return Number(intervalId); |
| 139 | } |
| 140 | |
| 141 | export function waitUntilTrue(condition: Function, callback: Function, interval = 200) { |
| 142 | // eslint-disable-next-line @typescript-eslint/no-misused-promises |