diff --git a/packages/app/src/thunk.ts b/packages/app/src/thunk.ts index 48aedca..ca38f5c 100644 --- a/packages/app/src/thunk.ts +++ b/packages/app/src/thunk.ts @@ -321,6 +321,15 @@ export const waitForThunkError = (thunk: Thunk) => }) }) +export const waitForThunkCompletion = (thunk: Thunk) => + new Promise(resolve => { + thunk.subscribe($thunk => { + if (thunkIsComplete($thunk)) { + resolve() + } + }) + }) + // Thunk state export const thunks = writable>({})