feat: animate completed items out
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 3m25s

This commit is contained in:
2026-09-11 08:56:51 +08:00
parent 36952fdbcc
commit 8b475e4df5
7 changed files with 121 additions and 22 deletions
+10 -4
View File
@@ -227,13 +227,15 @@ export async function runLatestRequest<T>(
return committed
}
type MutationSuccessCallback<T> = (value: T) => void | Promise<void>
export type MutationReconciler<TContext> = {
run<T>(
mutation: () => Promise<T>,
onSuccess: (value: T) => void,
onError?: (reason: unknown) => void,
onCurrentSuccess?: (value: T) => void,
): Promise<void>
onCurrentSuccess?: MutationSuccessCallback<T>,
): Promise<boolean>
}
export function createMutationReconciler<TContext>(
@@ -269,12 +271,16 @@ export function createMutationReconciler<TContext>(
value = await mutation()
} catch (reason) {
onError?.(reason)
return
return false
}
onSuccess(value)
if (sameContext(context, currentContext())) onCurrentSuccess?.(value)
if (sameContext(context, currentContext())) {
const currentSuccess = onCurrentSuccess?.(value)
if (currentSuccess instanceof Promise) await currentSuccess
}
await reconcile(context)
if (sameContext(context, currentContext()) && reconciled < dirty) await reconcile(context)
return true
},
}
}