feat(store): useMutation hook for react (#290)

This commit is contained in:
rahim
2026-01-07 00:10:41 +11:00
committed by GitHub
parent a71a280bdc
commit ecd4940bc7
23 changed files with 827 additions and 398 deletions
-7
View File
@@ -13,13 +13,6 @@ export type TaskKey<T = string | symbol> = T & (string | symbol);
export type EnsureTaskKey<T> = T extends string | symbol ? T : never;
/**
* Status for async operations (mutations, optimistic updates).
*
* Used by framework bindings (React, Lit) for tracking request lifecycle.
*/
export type AsyncStatus = 'idle' | 'pending' | 'success' | 'error';
/**
* A task scheduler controls when a task flushes.
*
@@ -1,24 +1,9 @@
import type { AsyncStatus, ErrorTask, PendingTask, SuccessTask, Task, TasksRecord } from '../queue';
import type { ErrorTask, PendingTask, SuccessTask, Task, TasksRecord } from '../queue';
import { describe, expectTypeOf, it } from 'vitest';
import { createQueue } from '../queue';
describe('queue types', () => {
describe('AsyncStatus', () => {
it('includes all status values', () => {
const idle: AsyncStatus = 'idle';
const pending: AsyncStatus = 'pending';
const success: AsyncStatus = 'success';
const error: AsyncStatus = 'error';
expectTypeOf(idle).toExtend<AsyncStatus>();
expectTypeOf(pending).toExtend<AsyncStatus>();
expectTypeOf(success).toExtend<AsyncStatus>();
expectTypeOf(error).toExtend<AsyncStatus>();
});
});
describe('Task', () => {
it('is discriminated union of task states', () => {
const task: Task = {} as Task;