@ngxs/store
Advanced tools
Comparing version 18.1.2-dev.master-cbc269d to 18.1.2-dev.master-eaf3f9d
@@ -1,1 +0,12 @@ | ||
export { withExperimentalNgxsPendingTasks } from './pending-tasks'; | ||
import * as _angular_core from '@angular/core'; | ||
/** | ||
* This is an experimental feature that contributes to app stability, | ||
* which is required during server-side rendering. With asynchronous | ||
* actions being dispatched and handled, Angular is unaware of them in | ||
* zoneless mode and doesn't know whether the app is still unstable. | ||
* This may prematurely serialize the final HTML that is sent to the client. | ||
*/ | ||
declare function withExperimentalNgxsPendingTasks(): _angular_core.EnvironmentProviders; | ||
export { withExperimentalNgxsPendingTasks }; |
751
index.d.ts
@@ -0,12 +1,751 @@ | ||
import * as i0 from '@angular/core'; | ||
import { Type, ModuleWithProviders, OnDestroy, NgZone, Signal, EnvironmentProviders } from '@angular/core'; | ||
import { ɵSharedSelectorOptions as _SharedSelectorOptions, ɵStateClass as _StateClass, ɵActionOptions as _ActionOptions, ɵPlainObjectOf as _PlainObjectOf, ɵStateClassInternal as _StateClassInternal, ɵActionHandlerMetaData as _ActionHandlerMetaData, ɵOrderedSubject as _OrderedSubject, ɵStateStream as _StateStream, ɵRuntimeSelectorContext as _RuntimeSelectorContext, StateToken, ɵStoreOptions as _StoreOptions } from '@ngxs/store/internals'; | ||
export { ɵActionOptions as ActionOptions, StateToken } from '@ngxs/store/internals'; | ||
import * as rxjs from 'rxjs'; | ||
import { Observable, Subject, Subscription, OperatorFunction } from 'rxjs'; | ||
import { StateOperator } from '@ngxs/store/operators'; | ||
export { StateOperator } from '@ngxs/store/operators'; | ||
import { NgxsPluginFn, NgxsPlugin } from '@ngxs/store/plugins'; | ||
export { InitState, NGXS_PLUGINS, NgxsNextPluginFn, NgxsPlugin, NgxsPluginFn, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue } from '@ngxs/store/plugins'; | ||
interface NgxsExecutionStrategy { | ||
enter<T>(func: () => T): T; | ||
leave<T>(func: () => T): T; | ||
} | ||
/** | ||
* The public api for consumers of @ngxs/store | ||
* The NGXS config settings. | ||
*/ | ||
export * from './src/public_api'; | ||
declare class NgxsConfig { | ||
/** | ||
* Run in development mode. This will add additional debugging features: | ||
* - Object.freeze on the state and actions to guarantee immutability | ||
* (default: false) | ||
* | ||
* Note: this property will be accounted only in development mode. | ||
* It makes sense to use it only during development to ensure there're no state mutations. | ||
* When building for production, the `Object.freeze` will be tree-shaken away. | ||
*/ | ||
developmentMode: boolean; | ||
compatibility: { | ||
/** | ||
* Support a strict Content Security Policy. | ||
* This will circumvent some optimisations that violate a strict CSP through the use of `new Function(...)`. | ||
* (default: false) | ||
*/ | ||
strictContentSecurityPolicy: boolean; | ||
}; | ||
/** | ||
* Determines the execution context to perform async operations inside. An implementation can be | ||
* provided to override the default behaviour where the async operations are run | ||
* outside Angular's zone but all observable behaviours of NGXS are run back inside Angular's zone. | ||
* These observable behaviours are from: | ||
* `store.selectSignal(...)`, `store.select(...)`, `actions.subscribe(...)` or `store.dispatch(...).subscribe(...)` | ||
* Every `zone.run` causes Angular to run change detection on the whole tree (`app.tick()`) so of your | ||
* application doesn't rely on zone.js running change detection then you can switch to the | ||
* `NoopNgxsExecutionStrategy` that doesn't interact with zones. | ||
* (default: null) | ||
*/ | ||
executionStrategy: Type<NgxsExecutionStrategy>; | ||
/** | ||
* Defining shared selector options | ||
*/ | ||
selectorOptions: _SharedSelectorOptions; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsConfig, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<NgxsConfig>; | ||
} | ||
/** | ||
* The plugin api for the stuff that a plugins needs | ||
* State context provided to the actions in the state. | ||
*/ | ||
export * from './src/plugin_api'; | ||
interface StateContext<T> { | ||
/** | ||
* Get the current state. | ||
*/ | ||
getState(): T; | ||
/** | ||
* Reset the state to a new value. | ||
*/ | ||
setState(val: T | StateOperator<T>): void; | ||
/** | ||
* Patch the existing state with the provided value. | ||
*/ | ||
patchState(val: Partial<T>): void; | ||
/** | ||
* Dispatch a new action and return the dispatched observable. | ||
*/ | ||
dispatch(actions: any | any[]): Observable<void>; | ||
} | ||
/** | ||
* Private exports required for the compilation. | ||
* Represents a basic change from a previous to a new value for a single state instance. | ||
* Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook. | ||
*/ | ||
export * from './src/private_api'; | ||
declare class NgxsSimpleChange<T = any> { | ||
readonly previousValue: T; | ||
readonly currentValue: T; | ||
readonly firstChange: boolean; | ||
constructor(previousValue: T, currentValue: T, firstChange: boolean); | ||
} | ||
/** | ||
* On init interface | ||
*/ | ||
interface NgxsOnInit { | ||
ngxsOnInit(ctx: StateContext<any>): void; | ||
} | ||
/** | ||
* On change interface | ||
*/ | ||
interface NgxsOnChanges { | ||
ngxsOnChanges(change: NgxsSimpleChange): void; | ||
} | ||
/** | ||
* After bootstrap interface | ||
*/ | ||
interface NgxsAfterBootstrap { | ||
ngxsAfterBootstrap(ctx: StateContext<any>): void; | ||
} | ||
type NgxsModuleOptions = Partial<NgxsConfig>; | ||
/** | ||
* @ignore | ||
*/ | ||
declare class NgxsRootModule { | ||
constructor(); | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsRootModule, never>; | ||
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsRootModule, never, never, never>; | ||
static ɵinj: i0.ɵɵInjectorDeclaration<NgxsRootModule>; | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
declare class NgxsFeatureModule { | ||
constructor(); | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsFeatureModule, never>; | ||
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsFeatureModule, never, never, never>; | ||
static ɵinj: i0.ɵɵInjectorDeclaration<NgxsFeatureModule>; | ||
} | ||
declare class NgxsModule { | ||
static forRoot(states?: _StateClass[], options?: NgxsModuleOptions): ModuleWithProviders<NgxsRootModule>; | ||
static forFeature(states?: _StateClass[]): ModuleWithProviders<NgxsFeatureModule>; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsModule, never>; | ||
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsModule, never, never, never>; | ||
static ɵinj: i0.ɵɵInjectorDeclaration<NgxsModule>; | ||
} | ||
interface ActionDef<TArgs extends any[] = any[], TReturn = any> { | ||
type: string; | ||
new (...args: TArgs): TReturn; | ||
} | ||
type ActionType = ActionDef | { | ||
type: string; | ||
}; | ||
/** | ||
* Given an action class, returns its payload. | ||
*/ | ||
type ActionToPayload<Action extends ActionType> = Action extends ActionDef<any, infer ActionPayload> ? ActionPayload : never; | ||
/** | ||
* Given a list of action classes, returns the union of their payloads. | ||
*/ | ||
type ActionsToPayload<Actions extends readonly ActionType[]> = { | ||
[K in keyof Actions]: ActionToPayload<Actions[K]>; | ||
}[number]; | ||
/** | ||
* Given an action class or a list of action classes, returns the union of their payloads. | ||
*/ | ||
type ActionOrActionsToPayload<ActionOrActions> = ActionOrActions extends ActionType ? ActionToPayload<ActionOrActions> : ActionOrActions extends ActionType[] ? ActionsToPayload<ActionOrActions> : never; | ||
/** | ||
* Describes what methods can be decorated with an `@Action` decorator that has been passed the given action(s). | ||
*/ | ||
type HandlerTypedPropertyDescriptor<ActionOrActions> = TypedPropertyDescriptor<() => any> | TypedPropertyDescriptor<(stateContext: StateContext<any>) => any> | TypedPropertyDescriptor<(stateContext: StateContext<any>, action: ActionOrActionsToPayload<ActionOrActions>) => any>; | ||
/** | ||
* The result of a call to the `@Action()` decorator with the given action(s) as its first argument. | ||
*/ | ||
type ActionDecorator<ActionOrActions extends ActionType | ActionType[]> = (target: any, name: string | symbol, _descriptor: HandlerTypedPropertyDescriptor<ActionOrActions>) => void; | ||
/** | ||
* Decorates a method with action information. | ||
*/ | ||
declare function Action<ActionOrActions extends ActionType | ActionType[]>(actions: ActionOrActions, options?: _ActionOptions): ActionDecorator<ActionOrActions>; | ||
declare class InternalNgxsExecutionStrategy implements NgxsExecutionStrategy { | ||
private _executionStrategy; | ||
constructor(_executionStrategy: NgxsExecutionStrategy); | ||
enter<T>(func: () => T): T; | ||
leave<T>(func: () => T): T; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<InternalNgxsExecutionStrategy, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<InternalNgxsExecutionStrategy>; | ||
} | ||
type StatesByName = _PlainObjectOf<_StateClassInternal>; | ||
interface StateOperations<T> { | ||
getState(): T; | ||
setState(val: T): void; | ||
dispatch(actionOrActions: any | any[]): Observable<void>; | ||
} | ||
interface MappedStore { | ||
name: string; | ||
isInitialised: boolean; | ||
actions: _PlainObjectOf<_ActionHandlerMetaData[]>; | ||
defaults: any; | ||
instance: any; | ||
path: string; | ||
} | ||
interface StatesAndDefaults { | ||
defaults: any; | ||
states: MappedStore[]; | ||
} | ||
/** | ||
* Status of a dispatched action | ||
*/ | ||
declare const enum ActionStatus { | ||
Dispatched = "DISPATCHED", | ||
Successful = "SUCCESSFUL", | ||
Canceled = "CANCELED", | ||
Errored = "ERRORED" | ||
} | ||
interface ActionContext<T = any> { | ||
status: ActionStatus; | ||
action: T; | ||
error?: Error; | ||
} | ||
/** | ||
* Internal Action stream that is emitted anytime an action is dispatched. | ||
*/ | ||
declare class InternalActions extends _OrderedSubject<ActionContext> implements OnDestroy { | ||
readonly dispatched$: Subject<ActionContext<any>>; | ||
constructor(); | ||
ngOnDestroy(): void; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<InternalActions, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<InternalActions>; | ||
} | ||
/** | ||
* Action stream that is emitted anytime an action is dispatched. | ||
* | ||
* You can listen to this in services to react without stores. | ||
*/ | ||
declare class Actions extends Observable<ActionContext> { | ||
constructor(internalActions$: InternalActions, internalExecutionStrategy: InternalNgxsExecutionStrategy); | ||
static ɵfac: i0.ɵɵFactoryDeclaration<Actions, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<Actions>; | ||
} | ||
declare class PluginManager { | ||
readonly plugins: NgxsPluginFn[]; | ||
private readonly _parentManager; | ||
private readonly _pluginHandlers; | ||
constructor(); | ||
private get _rootPlugins(); | ||
private registerHandlers; | ||
private getPluginHandlers; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<PluginManager, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<PluginManager>; | ||
} | ||
/** | ||
* Internal Action result stream that is emitted when an action is completed. | ||
* This is used as a method of returning the action result to the dispatcher | ||
* for the observable returned by the dispatch(...) call. | ||
* The dispatcher then asynchronously pushes the result from this stream onto the main action stream as a result. | ||
*/ | ||
declare class InternalDispatchedActionResults extends Subject<ActionContext> { | ||
static ɵfac: i0.ɵɵFactoryDeclaration<InternalDispatchedActionResults, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<InternalDispatchedActionResults>; | ||
} | ||
declare class InternalDispatcher { | ||
private _ngZone; | ||
private _actions; | ||
private _actionResults; | ||
private _pluginManager; | ||
private _stateStream; | ||
private _ngxsExecutionStrategy; | ||
constructor(_ngZone: NgZone, _actions: InternalActions, _actionResults: InternalDispatchedActionResults, _pluginManager: PluginManager, _stateStream: _StateStream, _ngxsExecutionStrategy: InternalNgxsExecutionStrategy); | ||
/** | ||
* Dispatches event(s). | ||
*/ | ||
dispatch(actionOrActions: any | any[]): Observable<void>; | ||
private dispatchByEvents; | ||
private dispatchSingle; | ||
private getActionResultStream; | ||
private createDispatchObservable; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<InternalDispatcher, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<InternalDispatcher>; | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
declare class InternalStateOperations { | ||
private _stateStream; | ||
private _dispatcher; | ||
private _config; | ||
constructor(_stateStream: _StateStream, _dispatcher: InternalDispatcher, _config: NgxsConfig); | ||
/** | ||
* Returns the root state operators. | ||
*/ | ||
getRootStateOperations(): StateOperations<any>; | ||
setStateToTheCurrentWithNew(results: StatesAndDefaults): void; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<InternalStateOperations, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<InternalStateOperations>; | ||
} | ||
/** | ||
* The `StateFactory` class adds root and feature states to the graph. | ||
* This extracts state names from state classes, checks if they already | ||
* exist in the global graph, throws errors if their names are invalid, etc. | ||
* See its constructor, state factories inject state factories that are | ||
* parent-level providers. This is required to get feature states from the | ||
* injector on the same level. | ||
* | ||
* The `NgxsModule.forFeature(...)` returns `providers: [StateFactory, ...states]`. | ||
* The `StateFactory` is initialized on the feature level and goes through `...states` | ||
* to get them from the injector through `injector.get(state)`. | ||
* @ignore | ||
*/ | ||
declare class StateFactory implements OnDestroy { | ||
private readonly _injector; | ||
private readonly _config; | ||
private readonly _parentFactory; | ||
private readonly _stateContextFactory; | ||
private readonly _actions; | ||
private readonly _actionResults; | ||
private readonly _initialState; | ||
private readonly _actionRegistry; | ||
private readonly _propGetter; | ||
private _actionsSubscription; | ||
private _ngxsUnhandledErrorHandler; | ||
private _states; | ||
get states(): MappedStore[]; | ||
private _statesByName; | ||
get statesByName(): StatesByName; | ||
private _statePaths; | ||
private get statePaths(); | ||
getRuntimeSelectorContext: () => _RuntimeSelectorContext; | ||
ngOnDestroy(): void; | ||
/** | ||
* Add a new state to the global defs. | ||
*/ | ||
add(stateClasses: _StateClassInternal[]): MappedStore[]; | ||
/** | ||
* Add a set of states to the store and return the defaults | ||
*/ | ||
addAndReturnDefaults(stateClasses: _StateClassInternal[]): StatesAndDefaults; | ||
connectActionHandlers(): void; | ||
/** | ||
* Invoke actions on the states. | ||
*/ | ||
invokeActions(action: any): rxjs.Observable<[void | Promise<void> | rxjs.Observable<unknown>]>; | ||
private addToStatesMap; | ||
private addRuntimeInfoToMeta; | ||
private hasBeenMountedAndBootstrapped; | ||
private hydrateActionMetasMap; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<StateFactory, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<StateFactory>; | ||
} | ||
type ɵSelectorFunc<TModel> = (...arg: any[]) => TModel; | ||
type TypedSelector<TModel> = StateToken<TModel> | ɵSelectorFunc<TModel>; | ||
type ɵStateSelector = _StateClass<any>; | ||
type ɵSelectorDef<TModel> = ɵStateSelector | TypedSelector<TModel>; | ||
type ɵSelectorReturnType<T extends ɵSelectorDef<any>> = T extends StateToken<infer R1> ? R1 : T extends ɵSelectorFunc<infer R2> ? R2 : T extends _StateClass<any> ? any : never; | ||
interface SelectorMap$1 { | ||
[key: string]: TypedSelector<any>; | ||
} | ||
type ModelSelector<T extends SelectorMap$1> = (...args: any[]) => MappedResult<T>; | ||
type MappedResult<TSelectorMap> = { | ||
[P in keyof TSelectorMap]: TSelectorMap[P] extends TypedSelector<infer R> ? R : never; | ||
}; | ||
declare function createModelSelector<T extends SelectorMap$1>(selectorMap: T): ModelSelector<T>; | ||
type KeysToValues<T, Keys extends (keyof T)[]> = { | ||
[Index in keyof Keys]: Keys[Index] extends keyof T ? T[Keys[Index]] : never; | ||
}; | ||
declare function createPickSelector<TModel, Keys extends (keyof TModel)[]>(selector: TypedSelector<TModel>, keys: [...Keys]): (...props: KeysToValues<TModel, Keys>) => Pick<TModel, Keys[number]>; | ||
type PropertySelectors<TModel> = { | ||
[P in keyof NonNullable<TModel>]-?: (model: TModel) => TModel extends null | undefined ? undefined : NonNullable<TModel>[P]; | ||
}; | ||
declare function createPropertySelectors<TModel>(parentSelector: ɵSelectorDef<TModel>): PropertySelectors<TModel>; | ||
interface CreationMetadata { | ||
containerClass: any; | ||
selectorName: string; | ||
getSelectorOptions?: () => _SharedSelectorOptions; | ||
} | ||
type SelectorArg = ɵSelectorDef<any>; | ||
/** | ||
* Function for creating a selector | ||
* @param selectors The selectors to use to create the arguments of this function | ||
* @param originalFn The original function being made into a selector | ||
* @param creationMetadata | ||
*/ | ||
declare function createSelector<S1 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>) => any>(selectors: [S1], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<S1 extends SelectorArg, S2 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>, s2: ɵSelectorReturnType<S2>) => any>(selectors: [S1, S2], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<S1 extends SelectorArg, S2 extends SelectorArg, S3 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>, s2: ɵSelectorReturnType<S2>, s3: ɵSelectorReturnType<S3>) => any>(selectors: [S1, S2, S3], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<S1 extends SelectorArg, S2 extends SelectorArg, S3 extends SelectorArg, S4 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>, s2: ɵSelectorReturnType<S2>, s3: ɵSelectorReturnType<S3>, s4: ɵSelectorReturnType<S4>) => any>(selectors: [S1, S2, S3, S4], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<S1 extends SelectorArg, S2 extends SelectorArg, S3 extends SelectorArg, S4 extends SelectorArg, S5 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>, s2: ɵSelectorReturnType<S2>, s3: ɵSelectorReturnType<S3>, s4: ɵSelectorReturnType<S4>, s5: ɵSelectorReturnType<S5>) => any>(selectors: [S1, S2, S3, S4, S5], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<S1 extends SelectorArg, S2 extends SelectorArg, S3 extends SelectorArg, S4 extends SelectorArg, S5 extends SelectorArg, S6 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>, s2: ɵSelectorReturnType<S2>, s3: ɵSelectorReturnType<S3>, s4: ɵSelectorReturnType<S4>, s5: ɵSelectorReturnType<S5>, s6: ɵSelectorReturnType<S6>) => any>(selectors: [S1, S2, S3, S4, S5, S6], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<S1 extends SelectorArg, S2 extends SelectorArg, S3 extends SelectorArg, S4 extends SelectorArg, S5 extends SelectorArg, S6 extends SelectorArg, S7 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>, s2: ɵSelectorReturnType<S2>, s3: ɵSelectorReturnType<S3>, s4: ɵSelectorReturnType<S4>, s5: ɵSelectorReturnType<S5>, s6: ɵSelectorReturnType<S6>, s7: ɵSelectorReturnType<S7>) => any>(selectors: [S1, S2, S3, S4, S5, S6, S7], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<S1 extends SelectorArg, S2 extends SelectorArg, S3 extends SelectorArg, S4 extends SelectorArg, S5 extends SelectorArg, S6 extends SelectorArg, S7 extends SelectorArg, S8 extends SelectorArg, TProjector extends (s1: ɵSelectorReturnType<S1>, s2: ɵSelectorReturnType<S2>, s3: ɵSelectorReturnType<S3>, s4: ɵSelectorReturnType<S4>, s5: ɵSelectorReturnType<S5>, s6: ɵSelectorReturnType<S6>, s7: ɵSelectorReturnType<S7>, s8: ɵSelectorReturnType<S8>) => any>(selectors: [S1, S2, S3, S4, S5, S6, S7, S8], projector: TProjector, creationMetadata?: Partial<CreationMetadata>): TProjector; | ||
declare function createSelector<T extends (...args: any[]) => any>(selectors: SelectorArg[] | undefined, projector: T, creationMetadata?: Partial<CreationMetadata>): T; | ||
declare class Store { | ||
private _stateStream; | ||
private _internalStateOperations; | ||
private _config; | ||
private _internalExecutionStrategy; | ||
private _stateFactory; | ||
/** | ||
* This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone, | ||
* because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`. | ||
* All selects would use this stream, and it would call leave only once for any state change across all active selectors. | ||
*/ | ||
private _selectableStateStream; | ||
constructor(_stateStream: _StateStream, _internalStateOperations: InternalStateOperations, _config: NgxsConfig, _internalExecutionStrategy: InternalNgxsExecutionStrategy, _stateFactory: StateFactory, initialStateValue: any); | ||
/** | ||
* Dispatches event(s). | ||
*/ | ||
dispatch(actionOrActions: any | any[]): Observable<void>; | ||
/** | ||
* Selects a slice of data from the store. | ||
*/ | ||
select<T>(selector: TypedSelector<T>): Observable<T>; | ||
/** | ||
* Select one slice of data from the store. | ||
*/ | ||
selectOnce<T>(selector: TypedSelector<T>): Observable<T>; | ||
/** | ||
* Select a snapshot from the state. | ||
*/ | ||
selectSnapshot<T>(selector: TypedSelector<T>): T; | ||
/** | ||
* Select a signal from the state. | ||
*/ | ||
selectSignal<T>(selector: TypedSelector<T>): Signal<T>; | ||
/** | ||
* Allow the user to subscribe to the root of the state | ||
*/ | ||
subscribe(fn?: (value: any) => void): Subscription; | ||
/** | ||
* Return the raw value of the state. | ||
*/ | ||
snapshot(): any; | ||
/** | ||
* Reset the state to a specific point in time. This method is useful | ||
* for plugin's who need to modify the state directly or unit testing. | ||
*/ | ||
reset(state: any): void; | ||
private getStoreBoundSelectorFn; | ||
private initStateStream; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<Store, [null, null, null, null, null, { optional: true; }]>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<Store>; | ||
} | ||
/** | ||
* Decorates a class with ngxs state information. | ||
*/ | ||
declare function State<T>(options: _StoreOptions<T>): (target: _StateClass) => void; | ||
/** | ||
* Decorator for selecting a slice of state from the store. | ||
* | ||
* @deprecated | ||
* Read the deprecation notice at this link: https://ngxs.io/deprecations/select-decorator-deprecation. | ||
*/ | ||
declare function Select<T>(rawSelector?: T, ...paths: string[]): PropertyDecorator; | ||
/** | ||
* Decorator for setting selector options at a method or class level. | ||
*/ | ||
declare function SelectorOptions(options: _SharedSelectorOptions): ClassDecorator & MethodDecorator; | ||
type TupleKeys<T extends any[]> = Exclude<keyof T, keyof []>; | ||
/** | ||
* Given a POJO, returns the POJO type, given a class constructor object, returns the type of the class. | ||
* | ||
* This utility type exists due to the complexity of ActionType being either an ActionDef class or the plain | ||
* `{ type: string }` type (or similar compatible POJO types). | ||
*/ | ||
type Constructed<T> = T extends new (...args: any[]) => infer U ? U : T; | ||
interface ActionCompletion<T = any, E = Error> { | ||
action: T; | ||
result: { | ||
successful: boolean; | ||
canceled: boolean; | ||
error?: E; | ||
}; | ||
} | ||
/** | ||
* RxJS operator for selecting out specific actions. | ||
* | ||
* This will grab actions that have just been dispatched as well as actions that have completed | ||
*/ | ||
declare function ofAction<T extends ActionType[]>(...allowedTypes: T): OperatorFunction<ActionContext<Constructed<T[TupleKeys<T>]>>, Constructed<T[TupleKeys<T>]>>; | ||
/** | ||
* RxJS operator for selecting out specific actions. | ||
* | ||
* This will ONLY grab actions that have just been dispatched | ||
*/ | ||
declare function ofActionDispatched<T extends ActionType[]>(...allowedTypes: T): OperatorFunction<ActionContext<Constructed<T[TupleKeys<T>]>>, Constructed<T[TupleKeys<T>]>>; | ||
/** | ||
* RxJS operator for selecting out specific actions. | ||
* | ||
* This will ONLY grab actions that have just been successfully completed | ||
*/ | ||
declare function ofActionSuccessful<T extends ActionType[]>(...allowedTypes: T): OperatorFunction<ActionContext<Constructed<T[TupleKeys<T>]>>, Constructed<T[TupleKeys<T>]>>; | ||
/** | ||
* RxJS operator for selecting out specific actions. | ||
* | ||
* This will ONLY grab actions that have just been canceled | ||
*/ | ||
declare function ofActionCanceled<T extends ActionType[]>(...allowedTypes: T): OperatorFunction<ActionContext<Constructed<T[TupleKeys<T>]>>, Constructed<T[TupleKeys<T>]>>; | ||
/** | ||
* RxJS operator for selecting out specific actions. | ||
* | ||
* This will ONLY grab actions that have just been completed | ||
*/ | ||
declare function ofActionCompleted<T extends ActionType[]>(...allowedTypes: T): OperatorFunction<ActionContext<Constructed<T[TupleKeys<T>]>>, ActionCompletion<Constructed<T[TupleKeys<T>]>>>; | ||
/** | ||
* RxJS operator for selecting out specific actions. | ||
* | ||
* This will ONLY grab actions that have just thrown an error | ||
*/ | ||
declare function ofActionErrored<T extends ActionType[]>(...allowedTypes: T): OperatorFunction<ActionContext<Constructed<T[TupleKeys<T>]>>, ActionCompletion<Constructed<T[TupleKeys<T>]>>>; | ||
/** | ||
* Defines a tuple of selector functions, state tokens, and state classes that a selector decorated | ||
* by `@Selector()` can depend on. | ||
*/ | ||
type SelectorDefTuple = ɵSelectorDef<any>[] | [ɵSelectorDef<any>]; | ||
type UnknownToAny<T> = unknown extends T ? any : T; | ||
type EnsureArray<T> = T extends any[] ? T : never; | ||
/** | ||
* Given a tuple of selector functions, state tokens, state classes, etc., returns a tuple of what | ||
* a dependent selector would expect to receive for that parent as an argument when called. | ||
* | ||
* For example, if the first element in `ParentsTuple` is a selector function that returns a | ||
* `number`, then the first element of the result tuple will be `number`. If the second element | ||
* in `ParentsTuple` is a state class with model `{ name: string }`, then the second element of | ||
* the result tuple will be `{ name: string }`. | ||
*/ | ||
type SelectorReturnTypeList<ParentsTuple extends SelectorDefTuple> = EnsureArray<{ | ||
[ParentsTupleIndex in keyof ParentsTuple]: ParentsTuple[ParentsTupleIndex] extends ɵSelectorDef<any> ? UnknownToAny<ɵSelectorReturnType<ParentsTuple[ParentsTupleIndex]>> : never; | ||
}>; | ||
/** | ||
* Defines a selector function matching a given argument list of parent selectors/states/tokens | ||
* and a given return type. | ||
*/ | ||
type SelectorSpec<ParentsTuple, Return> = ParentsTuple extends [] ? () => any : ParentsTuple extends SelectorDefTuple ? (...states: SelectorReturnTypeList<ParentsTuple>) => Return : () => any; | ||
/** | ||
* Defines a selector function matching `SelectorSpec<ParentsTuple, Return>` but with the assumption that the | ||
* container state has been injected as the first argument. | ||
*/ | ||
type SelectorSpecWithInjectedState<ParentsTuple, Return> = SelectorSpec<ParentsTuple extends SelectorDefTuple ? [any, ...ParentsTuple] : [any], ParentsTuple extends SelectorDefTuple ? Return : any>; | ||
/** | ||
* Defines a property descriptor for the `@Selector` decorator that decorates a function with | ||
* parent selectors/states/tokens `ParentsTuple` and return type `Return`. | ||
*/ | ||
type DescriptorWithNoInjectedState<ParentsTuple, Return> = TypedPropertyDescriptor<SelectorSpec<ParentsTuple, Return>>; | ||
/** | ||
* Same as `DescriptorWithNoInjectedState` but with state injected as the first argument. | ||
*/ | ||
type DescriptorWithInjectedState<ParentsTuple, Return> = TypedPropertyDescriptor<SelectorSpecWithInjectedState<ParentsTuple, Return>>; | ||
type DecoratorArgs<Descriptor> = [target: any, key: string | symbol, descriptor?: Descriptor]; | ||
/** | ||
* Defines the return type of a call to `@Selector` when there is no argument given | ||
* (e.g. `@Selector()` counts, but `@Selector([])` does not) | ||
* | ||
* This result is a decorator that can only be used to decorate a function with no arguments or a | ||
* single argument that is the container state. | ||
*/ | ||
type SelectorTypeNoDecoratorArgs = { | ||
<Return>(...args: DecoratorArgs<DescriptorWithNoInjectedState<unknown, Return>>): void | DescriptorWithNoInjectedState<unknown, Return>; | ||
<Return>(...args: DecoratorArgs<DescriptorWithInjectedState<unknown, Return>>): void | DescriptorWithInjectedState<unknown, Return>; | ||
}; | ||
/** | ||
* Defines the return type of a call to `@Selector` when there is an argument given. | ||
* (e.g. `@Selector([])` counts, but `@Selector()` does not) | ||
* | ||
* This result is a decorator that can only be used to decorate a function with an argument list | ||
* matching the results of the tuple of parents `ParentsTuple`. | ||
*/ | ||
type SelectorTypeWithDecoratorArgs<ParentsTuple> = { | ||
<Return>(...args: DecoratorArgs<DescriptorWithNoInjectedState<ParentsTuple, Return>>): void | DescriptorWithNoInjectedState<ParentsTuple, Return>; | ||
/** | ||
* @deprecated | ||
* Read the deprecation notice at this link: https://ngxs.io/deprecations/inject-container-state-deprecation.md. | ||
*/ | ||
<Return>(...args: DecoratorArgs<DescriptorWithInjectedState<ParentsTuple, Return>>): void | DescriptorWithInjectedState<ParentsTuple, Return>; | ||
}; | ||
/** | ||
* Defines the return type of a call to `@Selector`. This result is a decorator that can only be | ||
* used to decorate a function with an argument list matching `ParentsTuple`, the results of the | ||
* tuple of parent selectors/state tokens/state classes. | ||
*/ | ||
type SelectorType<ParentsTuple> = unknown extends ParentsTuple ? SelectorTypeNoDecoratorArgs : SelectorTypeWithDecoratorArgs<ParentsTuple>; | ||
/** | ||
* Decorator for creating a state selector for the current state. | ||
*/ | ||
declare function Selector(): SelectorType<unknown>; | ||
/** | ||
* Decorator for creating a state selector from the provided selectors (and optionally the container State, depending on the applicable Selector Options). | ||
*/ | ||
declare function Selector<T extends SelectorDefTuple>(selectors: T): SelectorType<T>; | ||
declare class NoopNgxsExecutionStrategy implements NgxsExecutionStrategy { | ||
enter<T>(func: () => T): T; | ||
leave<T>(func: () => T): T; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NoopNgxsExecutionStrategy, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<NoopNgxsExecutionStrategy>; | ||
} | ||
interface NgxsUnhandledErrorContext { | ||
action: any; | ||
} | ||
declare class NgxsUnhandledErrorHandler { | ||
private _ngZone; | ||
private _errorHandler; | ||
/** | ||
* The `_unhandledErrorContext` is left unused internally since we do not | ||
* require it for internal operations. However, developers who wish to provide | ||
* their own custom error handler may utilize this context information. | ||
*/ | ||
handleError(error: any, _unhandledErrorContext: NgxsUnhandledErrorContext): void; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsUnhandledErrorHandler, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<NgxsUnhandledErrorHandler>; | ||
} | ||
interface NgxsDevelopmentOptions { | ||
warnOnUnhandledActions: true | { | ||
ignore: ActionType[]; | ||
}; | ||
} | ||
declare class NgxsDevelopmentModule { | ||
static forRoot(options: NgxsDevelopmentOptions): ModuleWithProviders<NgxsDevelopmentModule>; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsDevelopmentModule, never>; | ||
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsDevelopmentModule, never, never, never>; | ||
static ɵinj: i0.ɵɵInjectorDeclaration<NgxsDevelopmentModule>; | ||
} | ||
declare function withNgxsDevelopmentOptions(options: NgxsDevelopmentOptions): i0.EnvironmentProviders; | ||
declare class NgxsUnhandledActionsLogger { | ||
/** | ||
* These actions should be ignored by default; the user can increase this | ||
* list in the future via the `ignoreActions` method. | ||
*/ | ||
private _ignoredActions; | ||
constructor(options: NgxsDevelopmentOptions); | ||
/** | ||
* Adds actions to the internal list of actions that should be ignored. | ||
*/ | ||
ignoreActions(...actions: ActionType[]): void; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsUnhandledActionsLogger, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<NgxsUnhandledActionsLogger>; | ||
} | ||
/** | ||
* This function provides global store providers and initializes the store. | ||
* | ||
* ```ts | ||
* bootstrapApplication(AppComponent, { | ||
* providers: [provideStore([CountriesState])] | ||
* }); | ||
* ``` | ||
* | ||
* The `provideStore` may be optionally called with a config before the list of features: | ||
* | ||
* ```ts | ||
* provideStore([CountriesState], { | ||
* developmentMode: !environment.production | ||
* }); | ||
* ``` | ||
*/ | ||
declare function provideStore(states?: _StateClass[], ...features: EnvironmentProviders[]): EnvironmentProviders; | ||
declare function provideStore(states?: _StateClass[], options?: NgxsModuleOptions, ...features: EnvironmentProviders[]): EnvironmentProviders; | ||
/** | ||
* This version serves as a standalone alternative to `NgxsModule.forFeature`. | ||
* It can be used in a similar manner to register feature states, but at the | ||
* `Route` providers level: | ||
* | ||
* ```ts | ||
* const routes: Routes = [ | ||
* { | ||
* path: 'products', | ||
* loadComponent: async () => {...}, | ||
* providers: [provideStates([ProductsState])] | ||
* } | ||
* ]; | ||
* ``` | ||
*/ | ||
declare function provideStates(states: _StateClass[], ...features: EnvironmentProviders[]): EnvironmentProviders; | ||
/** | ||
* This function registers a custom global plugin for the state. | ||
* | ||
* ```ts | ||
* bootstrapApplication(AppComponent, { | ||
* providers: [ | ||
* provideStore( | ||
* [CountriesState], | ||
* withNgxsPlugin(LogoutPlugin) | ||
* ) | ||
* ] | ||
* }); | ||
* ``` | ||
*/ | ||
declare function withNgxsPlugin(plugin: Type<NgxsPlugin>): EnvironmentProviders; | ||
/** | ||
* This function registers a preboot function which will be called before the root | ||
* store initializer is run, but after all of the NGXS features are provided and | ||
* available for injection. This is useful for registering action stream listeners | ||
* before any action is dispatched. | ||
* | ||
* ```ts | ||
* bootstrapApplication(AppComponent, { | ||
* providers: [ | ||
* provideStore( | ||
* [CountriesState], | ||
* withNgxsPreboot(() => { | ||
* const actions$ = inject(Actions); | ||
* actions$.subscribe(ctx => console.log(ctx)); | ||
* }) | ||
* ) | ||
* ] | ||
* }); | ||
* ``` | ||
*/ | ||
declare function withNgxsPreboot(prebootFn: VoidFunction): i0.EnvironmentProviders; | ||
/** | ||
* This function serves as a utility and has multiple purposes. | ||
* Firstly, it allows you to select properties from the state class | ||
* without having to inject the store class and use `this.store.selectSignal`, | ||
* resulting in a more concise implementation. Secondly, it can be used with | ||
* other solutions such as NgRx signal store with its `signalStoreFeature` or | ||
* `withComputed` functionalities. | ||
* | ||
* Please note that it's named `select` instead of `selectSignal` because | ||
* signals are evolving into first-class primitives in Angular, displacing other | ||
* primitives such as observables. Observables represent a stream of events, | ||
* whereas signals represent a single value changing over time. | ||
*/ | ||
declare function select<T>(selector: TypedSelector<T>): Signal<T>; | ||
declare function dispatch<TArgs extends any[]>(ActionType: ActionDef<TArgs>): (...args: TArgs) => rxjs.Observable<void>; | ||
type SelectorMap = Record<string, TypedSelector<unknown>>; | ||
declare function createSelectMap<T extends SelectorMap>(selectorMap: T): { readonly [K in keyof T]: Signal<ɵSelectorReturnType<T[K]>>; }; | ||
type ActionMap = Record<string, ActionDef<any>>; | ||
declare function createDispatchMap<T extends ActionMap>(actionMap: T): { readonly [K in keyof T]: (...args: ConstructorParameters<T[K]>) => Observable<void>; }; | ||
export { Action, type ActionCompletion, type ActionContext, type ActionDef, type ActionMap, ActionStatus, type ActionType, Actions, type NgxsAfterBootstrap, NgxsConfig, NgxsDevelopmentModule, type NgxsDevelopmentOptions, type NgxsExecutionStrategy, NgxsModule, type NgxsModuleOptions, type NgxsOnChanges, type NgxsOnInit, NgxsSimpleChange, NgxsUnhandledActionsLogger, type NgxsUnhandledErrorContext, NgxsUnhandledErrorHandler, NoopNgxsExecutionStrategy, type PropertySelectors, Select, Selector, type SelectorMap, SelectorOptions, State, type StateContext, Store, type TypedSelector, createDispatchMap, createModelSelector, createPickSelector, createPropertySelectors, createSelectMap, createSelector, dispatch, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, provideStates, provideStore, select, withNgxsDevelopmentOptions, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, type ɵSelectorDef, type ɵSelectorFunc, type ɵSelectorReturnType, type ɵStateSelector }; |
@@ -1,10 +0,206 @@ | ||
export * from './symbols'; | ||
export * from './metadata'; | ||
export { ɵmemoize } from './memoize'; | ||
export { StateToken } from './state-token'; | ||
export { ɵINITIAL_STATE_TOKEN, ɵInitialState } from './initial-state'; | ||
export { ɵNgxsAppBootstrappedState } from './ngxs-app-bootstrapped-state'; | ||
export { ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY } from './internal-tokens'; | ||
export { ɵOrderedSubject, ɵOrderedBehaviorSubject } from './custom-rxjs-subjects'; | ||
export { ɵwrapObserverCalls } from './custom-rxjs-operators'; | ||
export { ɵStateStream } from './state-stream'; | ||
import * as i0 from '@angular/core'; | ||
import { InjectionToken, OnDestroy, Signal } from '@angular/core'; | ||
import { ReplaySubject, Subject, BehaviorSubject, MonoTypeOperatorFunction } from 'rxjs'; | ||
declare class StateToken<T = void> { | ||
private readonly _name; | ||
constructor(_name: ɵTokenName<T>); | ||
getName(): string; | ||
toString(): string; | ||
} | ||
interface ɵPlainObject { | ||
[key: string]: any; | ||
} | ||
interface ɵPlainObjectOf<T> { | ||
[key: string]: T; | ||
} | ||
type ɵStateClass<T = any> = new (...args: any[]) => T; | ||
declare const ɵMETA_KEY = "NGXS_META"; | ||
declare const ɵMETA_OPTIONS_KEY = "NGXS_OPTIONS_META"; | ||
declare const ɵSELECTOR_META_KEY = "NGXS_SELECTOR_META"; | ||
interface ɵStateToken<T, U> { | ||
new (name: ɵTokenName<T>): U; | ||
getName(): string; | ||
toString(): string; | ||
} | ||
type RequireGeneric<T, U> = T extends void ? 'You must provide a type parameter' : U; | ||
type ɵTokenName<T> = string & RequireGeneric<T, string>; | ||
type ɵExtractTokenType<P> = P extends StateToken<infer T> ? T : never; | ||
/** | ||
* Options that can be provided to the store. | ||
*/ | ||
interface ɵStoreOptions<T> { | ||
/** | ||
* Name of the state. Required. | ||
*/ | ||
name: string | StateToken<T>; | ||
/** | ||
* Default values for the state. If not provided, uses empty object. | ||
*/ | ||
defaults?: T; | ||
/** | ||
* Sub states for the given state. | ||
* | ||
* @deprecated | ||
* Read the deprecation notice at this link: https://ngxs.io/deprecations/sub-states-deprecation. | ||
*/ | ||
children?: ɵStateClass[]; | ||
} | ||
interface ɵStateClassInternal<T = any, U = any> extends ɵStateClass<T> { | ||
[ɵMETA_KEY]?: ɵMetaDataModel; | ||
[ɵMETA_OPTIONS_KEY]?: ɵStoreOptions<U>; | ||
} | ||
interface ɵMetaDataModel { | ||
name: string | null; | ||
actions: ɵPlainObjectOf<ɵActionHandlerMetaData[]>; | ||
defaults: any; | ||
path: string | null; | ||
makeRootSelector: ɵSelectorFactory | null; | ||
/** @deprecated */ | ||
children?: ɵStateClassInternal[]; | ||
} | ||
interface ɵSelectorMetaDataModel { | ||
makeRootSelector: ɵSelectorFactory | null; | ||
originalFn: Function | null; | ||
containerClass: any; | ||
selectorName: string | null; | ||
getSelectorOptions: () => ɵSharedSelectorOptions; | ||
} | ||
interface ɵSharedSelectorOptions { | ||
/** | ||
* @deprecated | ||
* Read the deprecation notice at this link: https://ngxs.io/deprecations/inject-container-state-deprecation.md. | ||
*/ | ||
injectContainerState?: boolean; | ||
suppressErrors?: boolean; | ||
} | ||
interface ɵRuntimeSelectorContext { | ||
getStateGetter(key: any): (state: any) => any; | ||
getSelectorOptions(localOptions?: ɵSharedSelectorOptions): ɵSharedSelectorOptions; | ||
} | ||
type ɵSelectFromRootState = (rootState: any) => any; | ||
type ɵSelectorFactory = (runtimeContext: ɵRuntimeSelectorContext) => ɵSelectFromRootState; | ||
/** | ||
* Actions that can be provided in a action decorator. | ||
*/ | ||
interface ɵActionOptions { | ||
/** | ||
* Cancel the previous uncompleted observable(s). | ||
*/ | ||
cancelUncompleted?: boolean; | ||
} | ||
interface ɵActionHandlerMetaData { | ||
fn: string | symbol; | ||
options: ɵActionOptions; | ||
type: string; | ||
} | ||
/** | ||
* Ensures metadata is attached to the class and returns it. | ||
* | ||
* @ignore | ||
*/ | ||
declare function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel; | ||
/** | ||
* Get the metadata attached to the state class if it exists. | ||
* | ||
* @ignore | ||
*/ | ||
declare function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel; | ||
/** | ||
* Ensures metadata is attached to the selector and returns it. | ||
* | ||
* @ignore | ||
*/ | ||
declare function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel; | ||
/** | ||
* Get the metadata attached to the selector if it exists. | ||
* | ||
* @ignore | ||
*/ | ||
declare function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel; | ||
declare function defaultEqualityCheck(a: any, b: any): boolean; | ||
/** | ||
* Memoize a function on its last inputs only. | ||
* Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js | ||
* | ||
* @ignore | ||
*/ | ||
declare function ɵmemoize<T extends (...args: any[]) => any>(func: T, equalityCheck?: typeof defaultEqualityCheck): T; | ||
declare class ɵInitialState { | ||
private static _value; | ||
static set(state: ɵPlainObject): void; | ||
static pop(): ɵPlainObject; | ||
} | ||
declare const ɵINITIAL_STATE_TOKEN: InjectionToken<ɵPlainObject>; | ||
declare class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> { | ||
constructor(); | ||
bootstrap(): void; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgxsAppBootstrappedState, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<ɵNgxsAppBootstrappedState>; | ||
} | ||
declare const ɵNGXS_STATE_FACTORY: InjectionToken<any>; | ||
declare const ɵNGXS_STATE_CONTEXT_FACTORY: InjectionToken<any>; | ||
/** | ||
* Custom Subject that ensures that subscribers are notified of values in the order that they arrived. | ||
* A standard Subject does not have this guarantee. | ||
* For example, given the following code: | ||
* ```typescript | ||
* const subject = new Subject<string>(); | ||
subject.subscribe(value => { | ||
if (value === 'start') subject.next('end'); | ||
}); | ||
subject.subscribe(value => { }); | ||
subject.next('start'); | ||
* ``` | ||
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`. | ||
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`. | ||
*/ | ||
declare class ɵOrderedSubject<T> extends Subject<T> { | ||
private _orderedNext; | ||
next(value?: T): void; | ||
} | ||
/** | ||
* Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived. | ||
* A standard BehaviorSubject does not have this guarantee. | ||
* For example, given the following code: | ||
* ```typescript | ||
* const subject = new BehaviorSubject<string>(); | ||
subject.subscribe(value => { | ||
if (value === 'start') subject.next('end'); | ||
}); | ||
subject.subscribe(value => { }); | ||
subject.next('start'); | ||
* ``` | ||
* When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`. | ||
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`. | ||
*/ | ||
declare class ɵOrderedBehaviorSubject<T> extends BehaviorSubject<T> { | ||
private _orderedNext; | ||
private _currentValue; | ||
constructor(value: T); | ||
getValue(): T; | ||
next(value: T): void; | ||
} | ||
declare function ɵwrapObserverCalls<TValue>(invokeFn: (fn: () => void) => void): MonoTypeOperatorFunction<TValue>; | ||
/** | ||
* BehaviorSubject of the entire state. | ||
* @ignore | ||
*/ | ||
declare class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy { | ||
readonly state: Signal<ɵPlainObject>; | ||
constructor(); | ||
ngOnDestroy(): void; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<ɵStateStream, never>; | ||
static ɵprov: i0.ɵɵInjectableDeclaration<ɵStateStream>; | ||
} | ||
export { StateToken, type ɵActionHandlerMetaData, type ɵActionOptions, type ɵExtractTokenType, ɵINITIAL_STATE_TOKEN, ɵInitialState, ɵMETA_KEY, ɵMETA_OPTIONS_KEY, type ɵMetaDataModel, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, ɵNgxsAppBootstrappedState, ɵOrderedBehaviorSubject, ɵOrderedSubject, type ɵPlainObject, type ɵPlainObjectOf, type ɵRuntimeSelectorContext, ɵSELECTOR_META_KEY, type ɵSelectFromRootState, type ɵSelectorFactory, type ɵSelectorMetaDataModel, type ɵSharedSelectorOptions, type ɵStateClass, type ɵStateClassInternal, ɵStateStream, type ɵStateToken, type ɵStoreOptions, type ɵTokenName, ɵensureSelectorMetadata, ɵensureStoreMetadata, ɵgetSelectorMetadata, ɵgetStoreMetadata, ɵmemoize, ɵwrapObserverCalls }; |
@@ -1,4 +0,31 @@ | ||
export { freshPlatform } from './fresh-platform'; | ||
export { NgxsTestBed } from './ngxs.setup'; | ||
export { skipConsoleLogging, ConsoleRecord, ConsoleRecorder, loggedError } from './skip-console-logging'; | ||
export { NgxsTesting } from './symbol'; | ||
import { Store, NgxsModuleOptions } from '@ngxs/store'; | ||
import { ModuleWithProviders } from '@angular/core'; | ||
import { TestBedStatic } from '@angular/core/testing'; | ||
import { ɵStateClass as _StateClass } from '@ngxs/store/internals'; | ||
declare function freshPlatform(fn: (done?: VoidFunction) => Promise<void>): () => Promise<void>; | ||
interface NgxsOptionsTesting { | ||
states?: _StateClass[]; | ||
ngxsOptions?: NgxsModuleOptions; | ||
imports?: ModuleWithProviders<any>[]; | ||
before?: () => void; | ||
} | ||
interface NgxsTesting { | ||
store: Store; | ||
getTestBed: TestBedStatic; | ||
} | ||
declare class NgxsTestBed { | ||
static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting; | ||
private static ngxsBootstrap; | ||
private static resetTestBed; | ||
private static createRootNode; | ||
} | ||
type ConsoleRecord = [string, any[]]; | ||
type ConsoleRecorder = ConsoleRecord[]; | ||
declare function loggedError(message: string): ConsoleRecord; | ||
declare function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T, consoleRecorder?: ConsoleRecorder): ReturnType<T>; | ||
export { type ConsoleRecord, type ConsoleRecorder, NgxsTestBed, type NgxsTesting, freshPlatform, loggedError, skipConsoleLogging }; |
@@ -0,14 +1,102 @@ | ||
type _NoInfer<T> = T extends infer S ? S : never; | ||
/** | ||
* @module | ||
* @description | ||
* Entry point for all public APIs of this package. | ||
* Blocks the ability of the typescript inferrence engine to be able to use the provided type as part of | ||
* inferring any type parameters from this usage. | ||
* @example | ||
* Primarily used to wrap parameters of functions in order to prevent the TypeScript inferrence engine | ||
* from inferring a type parameter of the function from the value provided to this parameter. | ||
* This essentially blocks the Contravariance of the function (through its parameters) so that the | ||
* function type parameter is purely determined by the Covariant requirements of the function's return type. | ||
* This is key to creating `StateOperator`s that are typed based on their contextual usage and not on the arguments | ||
* provided to them. This is critical for type safety and intellisense for State Operators. | ||
* Here is an example of how this benefits a state operator: | ||
* ```ts | ||
* declare function append<T>(items: NoInfer<T[]>): StateOperator<T[]>; | ||
* declare function appendBad<T>(items: T[]): StateOperator<T[]>; | ||
* | ||
* interface AAA { | ||
* foo?: boolean; | ||
* bar?: boolean; | ||
* } | ||
* | ||
* // Works | ||
* // (T in append is correctly inferred as AAA) | ||
* patch<{ test: AAA[] }>({ test: append([{ foo: true }]) }); | ||
* | ||
* // Incorrectly throws: Type 'AAA' is not assignable to type '{ foo: true; }'.ts(2322) | ||
* // (T in appendBad is incorrectly inferred as { foo: true; }) | ||
* patch<{ test: AAA[] }>({ test: appendBad([{ foo: true }]) }); | ||
* ``` | ||
* | ||
*/ | ||
export { append } from './append'; | ||
export { compose } from './compose'; | ||
export { iif } from './iif'; | ||
export { insertItem } from './insert-item'; | ||
export { patch, ɵPatchSpec } from './patch'; | ||
export { isStateOperator, isPredicate, Predicate } from './utils'; | ||
export { updateItem } from './update-item'; | ||
export { removeItem } from './remove-item'; | ||
export { ExistingState, NoInfer, StateOperator } from './types'; | ||
type NoInfer<T> = T extends (infer O)[] ? _NoInfer<O>[] : _NoInfer<T>; | ||
/** | ||
* IMPORTANT NOTE: This should not be used externally to the library, rather | ||
* the exported type `ExistingState<T>` should be used instead. | ||
* | ||
* Used to convert a type to its readonly form. This can be given any type, from | ||
* primitives to objects or arrays that could already be readonly or not. | ||
* This does not apply the readonly construct to nested objects, but only to the top level type. | ||
*/ | ||
type ɵAsReadonly<T> = T extends Readonly<infer O> ? (O extends T ? Readonly<T> : T) : T; | ||
/** | ||
* Represents the existing state that is passed into a `StateOperator` which should | ||
* not be modified but will be used to build the new state returned by the `StateOperator`. | ||
*/ | ||
type ExistingState<T> = T extends any ? ɵAsReadonly<T> : never; | ||
/** | ||
* This is a monotype unary function that is used to create a new state from an existing state. | ||
* A state operator is usually created by a function that is given some data | ||
* to integrate with the state and returns a state operator which integrates this data or instruction. | ||
* | ||
* In state management terminology this creator function is commonly referred to as a state operator | ||
* because it represents the operation to be performed. ie. `patch`, `append`, `insertItem`, `compose`, `iif`, etc. | ||
*/ | ||
type StateOperator<T> = (existing: ExistingState<T>) => T; | ||
/** | ||
* @param items - Specific items to append to the end of an array | ||
*/ | ||
declare function append<T>(items: NoInfer<T[]>): StateOperator<T[]>; | ||
declare function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T>; | ||
type Predicate<T = any> = (value: T | Readonly<T>) => boolean; | ||
declare function isStateOperator<T>(value: T | StateOperator<T>): value is StateOperator<T>; | ||
declare function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T>; | ||
/** | ||
* @param condition - Condition can be a plain boolean value or a function, | ||
* that returns boolean, also this function can take a value as an argument | ||
* to which this state operator applies | ||
* @param trueOperatorOrValue - Any value or a state operator | ||
* @param elseOperatorOrValue - Any value or a state operator | ||
*/ | ||
declare function iif<T>(condition: NoInfer<Predicate<T>> | boolean, trueOperatorOrValue: NoInfer<StateOperator<T> | T>, elseOperatorOrValue?: NoInfer<StateOperator<T> | T>): StateOperator<T>; | ||
/** | ||
* @param value - Value to insert | ||
* @param [beforePosition] - Specified index to insert value before, optional | ||
*/ | ||
declare function insertItem<T>(value: NoInfer<T>, beforePosition?: number): StateOperator<T[]>; | ||
type NotUndefined<T> = T extends undefined ? never : T; | ||
type ɵPatchSpec<T> = { | ||
[P in keyof T]?: T[P] | StateOperator<NotUndefined<T[P]>>; | ||
}; | ||
declare function patch<T extends Record<string, any>>(patchObject: NoInfer<ɵPatchSpec<T>>): StateOperator<T>; | ||
/** | ||
* @param selector - Index of item in the array or a predicate function | ||
* that can be provided in `Array.prototype.findIndex` | ||
* @param operatorOrValue - New value under the `selector` index or a | ||
* function that can be applied to an existing value | ||
*/ | ||
declare function updateItem<T>(selector: number | NoInfer<Predicate<T>>, operatorOrValue: NoInfer<T> | NoInfer<StateOperator<T>>): StateOperator<T[]>; | ||
/** | ||
* @param selector - index or predicate to remove an item from an array by | ||
*/ | ||
declare function removeItem<T>(selector: number | NoInfer<Predicate<T>>): StateOperator<T[]>; | ||
export { type ExistingState, type NoInfer, type Predicate, type StateOperator, append, compose, iif, insertItem, isPredicate, isStateOperator, patch, removeItem, updateItem, type ɵPatchSpec }; |
{ | ||
"name": "@ngxs/store", | ||
"version": "18.1.2-dev.master-cbc269d", | ||
"version": "18.1.2-dev.master-eaf3f9d", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -1,3 +0,62 @@ | ||
export { InitState, UpdateState } from './actions'; | ||
export { NGXS_PLUGINS, NgxsPlugin, NgxsPluginFn, NgxsNextPluginFn } from './symbols'; | ||
export { getActionTypeFromInstance, actionMatcher, setValue, getValue } from './utils'; | ||
import { ɵPlainObject as _PlainObject } from '@ngxs/store/internals'; | ||
import { InjectionToken } from '@angular/core'; | ||
/** | ||
* Init action | ||
*/ | ||
declare class InitState { | ||
static readonly type = "@@INIT"; | ||
} | ||
/** | ||
* Update action | ||
*/ | ||
declare class UpdateState { | ||
readonly addedStates?: _PlainObject | undefined; | ||
static readonly type = "@@UPDATE_STATE"; | ||
constructor(addedStates?: _PlainObject | undefined); | ||
} | ||
declare const NGXS_PLUGINS: InjectionToken<unknown>; | ||
type NgxsPluginFn = (state: any, mutation: any, next: NgxsNextPluginFn) => any; | ||
type NgxsNextPluginFn = (state: any, mutation: any) => any; | ||
/** | ||
* Plugin interface | ||
*/ | ||
interface NgxsPlugin { | ||
/** | ||
* Handle the state/action before its submitted to the state handlers. | ||
*/ | ||
handle(state: any, action: any, next: NgxsNextPluginFn): any; | ||
} | ||
/** | ||
* Returns the type from an action instance/class. | ||
* @ignore | ||
*/ | ||
declare function getActionTypeFromInstance(action: any): string | undefined; | ||
/** | ||
* Matches a action | ||
* @ignore | ||
*/ | ||
declare function actionMatcher(action1: any): (action2: any) => boolean; | ||
/** | ||
* Set a deeply nested value. Example: | ||
* | ||
* setValue({ foo: { bar: { eat: false } } }, | ||
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } } | ||
* | ||
* While it traverses it also creates new objects from top down. | ||
* | ||
* @ignore | ||
*/ | ||
declare const setValue: (obj: any, prop: string, val: any) => any; | ||
/** | ||
* Get a deeply nested value. Example: | ||
* | ||
* getValue({ foo: bar: [] }, 'foo.bar') //=> [] | ||
* | ||
* @ignore | ||
*/ | ||
declare const getValue: (obj: any, prop: string) => any; | ||
export { InitState, NGXS_PLUGINS, type NgxsNextPluginFn, type NgxsPlugin, type NgxsPluginFn, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1010938
183
8381