Improve feed loader, wait for db before executing reads/updates, make taskQueue subscribable, add race, rename auth methods, fix failed wasm verify, fix localhost urls

This commit is contained in:
Jon Staab
2025-04-09 15:39:07 -07:00
parent 1bcc57d695
commit 859f7fa68f
14 changed files with 155 additions and 32 deletions
+13
View File
@@ -6,6 +6,7 @@ export type TaskQueueOptions<Item> = {
}
export class TaskQueue<Item> {
_subs: ((item: Item) => void)[] = []
items: Item[] = []
isPaused = false
isProcessing = false
@@ -21,6 +22,14 @@ export class TaskQueue<Item> {
this.items = remove(item, this.items)
}
subscribe(subscriber: (item: Item) => void) {
this._subs.push(subscriber)
return () => {
this._subs = remove(subscriber, this._subs)
}
}
async process() {
if (this.isProcessing || this.isPaused || this.items.length === 0) {
return
@@ -32,6 +41,10 @@ export class TaskQueue<Item> {
for (const item of this.items.splice(0, this.options.batchSize)) {
try {
for (const subscriber of this._subs) {
subscriber(item)
}
await this.options.processItem(item)
} catch (e) {
console.error(e)