Work on client modes

This commit is contained in:
Zef Hemel
2023-08-29 21:17:29 +02:00
parent 5ff1a8bae3
commit 9a005f26b5
54 changed files with 594 additions and 302 deletions
-32
View File
@@ -1,32 +0,0 @@
export function throttle(func: () => void, limit: number) {
let timer: any = null;
return function () {
if (!timer) {
timer = setTimeout(() => {
func();
timer = null;
}, limit);
}
};
}
// race for promises returns first promise that resolves
export function race<T>(promises: Promise<T>[]): Promise<T> {
return new Promise((resolve, reject) => {
for (const p of promises) {
p.then(resolve, reject);
}
});
}
export function timeout(ms: number): Promise<never> {
return new Promise((_resolve, reject) =>
setTimeout(() => {
reject(new Error("timeout"));
}, ms)
);
}
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
+3 -3
View File
@@ -115,9 +115,9 @@ export class EventedSpacePrimitives implements SpacePrimitives {
console.error("Error dispatching page:saved event", e);
});
}
if (name.startsWith("_plug/") && name.endsWith(".plug.js")) {
await this.dispatchEvent("plug:changed", name);
}
// if (name.startsWith("_plug/") && name.endsWith(".plug.js")) {
// await this.dispatchEvent("plug:changed", name);
// }
return newMeta;
}