mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(core): add error feature (#713)
This commit is contained in:
@@ -7,6 +7,7 @@ import type { AnySlice, InferSliceState, StateContext } from './slice';
|
||||
const stateContext: StateContext<unknown> = {
|
||||
target: throwNoTargetError,
|
||||
signals: new AbortControllerRegistry(),
|
||||
set: throwNoTargetError,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,8 @@ export interface StateContext<Target> {
|
||||
* (e.g., loading a new source cancels pending seeks).
|
||||
*/
|
||||
signals: AbortControllerRegistry;
|
||||
/** Patch the slice state. Safe to use inside action closures (not during `state()` init). */
|
||||
set: (partial: Record<string, unknown>) => void;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
@@ -38,6 +38,7 @@ export function createStore<Target = unknown>(): <State>(
|
||||
return target!;
|
||||
},
|
||||
signals,
|
||||
set: (partial) => state.patch(partial as Partial<State>),
|
||||
} satisfies StateContext<Target>);
|
||||
|
||||
state = createState(initialState);
|
||||
|
||||
Reference in New Issue
Block a user