@ngxs/store
Version:
50 lines (49 loc) • 1.74 kB
TypeScript
import { Subject, Observable } from 'rxjs';
import { InternalNgxsExecutionStrategy } from './execution/internal-ngxs-execution-strategy';
/**
* Status of a dispatched action
*/
export declare const enum ActionStatus {
Dispatched = "DISPATCHED",
Successful = "SUCCESSFUL",
Canceled = "CANCELED",
Errored = "ERRORED"
}
export interface ActionContext<T = any> {
status: ActionStatus;
action: T;
error?: Error;
}
/**
* 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`.
*/
export declare class OrderedSubject<T> extends Subject<T> {
private _itemQueue;
private _busyPushingNext;
next(value?: T): void;
}
/**
* Internal Action stream that is emitted anytime an action is dispatched.
*/
export declare class InternalActions extends OrderedSubject<ActionContext> {
}
/**
* Action stream that is emitted anytime an action is dispatched.
*
* You can listen to this in services to react without stores.
*/
export declare class Actions extends Observable<any> {
constructor(internalActions$: InternalActions, internalExecutionStrategy: InternalNgxsExecutionStrategy);
}