mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(store): useMutation hook for react (#290)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user