}
}
+export type RouteDataResponse<T extends Record<string, any>> = {
+ [K in keyof T]: RequestState<Exclude<T[K], undefined>>;
+};
++
+ function sleep(millis: number): Promise<void> {
+ return new Promise(resolve => setTimeout(resolve, millis));
+ }
+
+ /**
+ * Polls / repeatedly runs a promise, every X milliseconds
+ */
+ export async function poll(promiseFn: any, millis: number) {
+ if (window.document.visibilityState !== "hidden") {
+ await promiseFn();
+ }
+ await sleep(millis);
+ return poll(promiseFn, millis);
+ }