cross-state 0.30.1 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/scope2.cjs +25 -7
- package/dist/cjs/scope2.cjs.map +1 -1
- package/dist/cjs/store.cjs +26 -6
- package/dist/cjs/store.cjs.map +1 -1
- package/dist/es/scope2.mjs +25 -7
- package/dist/es/scope2.mjs.map +1 -1
- package/dist/es/store.mjs +26 -6
- package/dist/es/store.mjs.map +1 -1
- package/dist/types/core/store.d.ts +7 -2
- package/dist/types/lib/promiseWithCancel.d.ts +1 -1
- package/dist/types/react/useCache.d.ts +2 -1
- package/package.json +1 -1
|
@@ -15,6 +15,10 @@ export interface StoreOptionsWithMethods<T, Methods extends StoreMethods> extend
|
|
|
15
15
|
export type Calculate<T> = (this: CalculationHelpers<T>, helpers: CalculationHelpers<T>) => T;
|
|
16
16
|
type StandardMethods<T> = T extends Map<any, any> ? typeof mapMethods : T extends Set<any> ? typeof setMethods : T extends Array<any> ? typeof arrayMethods : T extends Record<any, any> ? typeof recordMethods : Record<string, never>;
|
|
17
17
|
type StoreWithMethods<T, Methods extends StoreMethods> = Store<T> & Omit<BoundStoreMethods<T, Methods>, keyof Store<T>> & StandardMethods<T>;
|
|
18
|
+
export interface OnceOptions {
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
timeout?: Duration;
|
|
21
|
+
}
|
|
18
22
|
export declare class Store<T> extends Callable<any, any> {
|
|
19
23
|
readonly getter: T | Calculate<T>;
|
|
20
24
|
readonly options: StoreOptions;
|
|
@@ -45,8 +49,9 @@ export declare class Store<T> extends Callable<any, any> {
|
|
|
45
49
|
set<const P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;
|
|
46
50
|
reset(): void;
|
|
47
51
|
subscribe(listener: Listener<T>, options?: SubscribeOptions): Cancel;
|
|
48
|
-
once<S extends T>(condition: (value: T) => value is S): PromiseWithCancel<S>;
|
|
49
|
-
once(condition
|
|
52
|
+
once<S extends T>(condition: (value: T) => value is S, options?: OnceOptions): PromiseWithCancel<S>;
|
|
53
|
+
once(condition: (value: T) => boolean, options?: OnceOptions): PromiseWithCancel<T>;
|
|
54
|
+
once(options?: OnceOptions): PromiseWithCancel<T>;
|
|
50
55
|
map<S>(selector: Selector<T, S>, updater?: (value: S) => Update<T>): Store<S>;
|
|
51
56
|
map<P extends Path<T>>(selector: P): Store<Value<T, P>>;
|
|
52
57
|
/** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.
|
|
@@ -4,5 +4,5 @@ export declare class PromiseCancelError extends Error {
|
|
|
4
4
|
export declare class PromiseWithCancel<T> extends Promise<T> {
|
|
5
5
|
private abortController;
|
|
6
6
|
constructor(executor: (resolve: (value: T) => void, reject: (error: unknown) => void, signal: AbortSignal) => void);
|
|
7
|
-
cancel(): void;
|
|
7
|
+
cancel(reason?: any): void;
|
|
8
8
|
}
|
|
@@ -10,6 +10,7 @@ export type UseCacheArray<T> = [
|
|
|
10
10
|
export type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;
|
|
11
11
|
export interface UseCacheOptions<T> extends UseStoreOptions<UseCacheArray<T> & CacheState<T>> {
|
|
12
12
|
passive?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
updateOnMount?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare function useCache<T>(cache: Cache<T>, { passive, updateOnMount, withViewTransition, ...options }?: UseCacheOptions<T>): UseCacheValue<T>;
|
|
16
|
+
export declare function useCache<T>(cache: Cache<T>, { passive, disabled, updateOnMount, withViewTransition, ...options }?: UseCacheOptions<T>): UseCacheValue<T>;
|