@zedux/stores
Version:
The legacy composable store model of Zedux
126 lines (125 loc) • 3.48 kB
TypeScript
import { Dispatchable, RecursivePartial, Settable } from '@zedux/core';
import { AtomGenerics, AnyAtomGenerics } from './types';
import { AtomInstance as NewAtomInstance, Cleanup, Ecosystem, ExportsInfusedSetter, PromiseStatus, InternalEvaluationReason, ExplicitEvents, Transaction } from '@zedux/atoms';
import { InjectorDescriptor } from './atoms-port';
import { AtomTemplate } from './AtomTemplate';
declare const StoreState = 1;
declare const RawState = 2;
export declare class AtomInstance<G extends Omit<AtomGenerics, 'Node' | 'Template'> & {
Template: AtomTemplate<G & {
Node: any;
}>;
} = AnyAtomGenerics<{
Node: any;
}>> extends NewAtomInstance<G> {
/**
* @see NewAtomInstance.e
*/
readonly e: Ecosystem;
/**
* @see NewAtomInstance.t
*/
readonly t: G['Template'];
/**
* @see NewAtomInstance.id
*/
readonly id: string;
/**
* @see NewAtomInstance.p
*/
readonly p: G['Params'];
static $$typeof: symbol;
store: G['Store'];
/**
* @see NewAtomInstance.c
*/
c?: Cleanup;
_createdAt: number;
_injectors?: InjectorDescriptor[];
_isEvaluating?: boolean;
_nextInjectors?: InjectorDescriptor[];
_promiseError?: Error;
_promiseStatus?: PromiseStatus;
_stateType?: typeof StoreState | typeof RawState;
private _bufferedUpdate?;
private _subscription?;
constructor(
/**
* @see NewAtomInstance.e
*/
e: Ecosystem,
/**
* @see NewAtomInstance.t
*/
t: G['Template'],
/**
* @see NewAtomInstance.id
*/
id: string,
/**
* @see NewAtomInstance.p
*/
p: G['Params']);
/**
* @see NewAtomInstance.destroy
*/
destroy(force?: boolean): void;
/**
* An alias for `.store.dispatch()`
*/
dispatch: (action: Dispatchable) => any;
/**
* An alias for `instance.store.getState()`. Returns the current state of this
* atom instance's store.
*
* @deprecated - use `.get()` instead @see AtomInstance.get
*/
getState(): G['State'];
/**
* @see NewAtomInstance.get
*
* An alias for `instance.store.getState()`.
*/
get(): any;
/**
* Force this atom instance to reevaluate.
*/
invalidate(): void;
/**
* `.mutate()` is not supported in legacy, store-based atoms. Upgrade to the
* new `atom()` factory.
*/
mutate(): [G['State'], Transaction[]];
set(settable: Settable<G['State']>, events?: Partial<G['Events'] & ExplicitEvents>): G["State"];
/**
* An alias for `.store.setState()`
*/
setState: (settable: Settable<G["State"]>, meta?: any) => G["State"];
/**
* An alias for `.store.setStateDeep()`
*/
setStateDeep: (settable: Settable<RecursivePartial<G["State"]>, G["State"]>, meta?: any) => G["State"];
/**
* @see NewAtomInstance.j
*/
j(): void;
/**
* @see NewAtomInstance.r
*/
r(reason: InternalEvaluationReason, shouldSetTimeout?: boolean): void;
_set?: ExportsInfusedSetter<G['State'], G['Exports']>;
get _infusedSetter(): any;
/**
* A standard atom's value can be one of:
*
* - A raw value
* - A Zedux store
* - A function that returns a raw value
* - A function that returns a Zedux store
* - A function that returns an AtomApi
*/
private _eval;
private _handleStateChange;
private _setPromise;
}
export {};