Add waitForThunkCompletion

This commit is contained in:
Jon Staab
2025-09-11 12:30:41 -07:00
parent 599e6a5085
commit 80944e64a7
+9
View File
@@ -321,6 +321,15 @@ export const waitForThunkError = (thunk: Thunk) =>
})
})
export const waitForThunkCompletion = (thunk: Thunk) =>
new Promise<void>(resolve => {
thunk.subscribe($thunk => {
if (thunkIsComplete($thunk)) {
resolve()
}
})
})
// Thunk state
export const thunks = writable<Record<string, AbstractThunk>>({})