@rx-angular/state
Version:
@rx-angular/state is a light-weight, flexible, strongly typed and tested tool dedicated to reduce the complexity of managing component state and side effects in angular
64 lines • 2.57 kB
TypeScript
import { OperatorFunction } from 'rxjs';
import { NonUndefined } from '../interfaces';
/**
* @description
*
* As the name `stateful` implies this operator is useful when you process an Observable which maintains state.
*
* Maintaining state as an `Observable` source comes with a handful of repetitive as well as use case specific tasks.
*
* It acts like the Observables `pipe` method.
* It accepts RxJS operators and composes them like `Observable#pipe` and the standalone `pipe` method.
*
* Furthermore, it takes care of the above mentioned repetitive tasks as listed below.
*
* You will always (aka repetitive) want to ensure that:
* - only distinct state changes are emitted
* - only defined values are emitted (filter out undefined, which ensures lazy state)
* - share and replay custom operations for multiple subscribers (saves performance)
*
* You will sometimes (aka situational) need:
* - a subset of the state (derivations)
* - compose the state with other Observables or change the Observables behaviour
*
*
* @example
* import { Observable } from 'rxjs';
* import { map } from 'rxjs/operators';
* import { stateful } from 'rx-angular/state';
*
* const state$: Observable<{ name: string; items: string[] }>;
* const derivation$ = state$.pipe(
* stateful(
* map(state => state.list.length),
* filter(length => length > 3)
* )
* );
*
* @return OperatorFunction<T, NonUndefined<A>>
*
* @docsPage stateful
* @docsCategory operators
*/
export declare function stateful<T>(): OperatorFunction<T, NonUndefined<T>>;
/**
* @internal
*/
export declare function stateful<T, A>(op: OperatorFunction<T, A>): OperatorFunction<T, NonUndefined<A>>;
/**
* @internal
*/
export declare function stateful<T, A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): OperatorFunction<T, NonUndefined<B>>;
/**
* @internal
*/
export declare function stateful<T, A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): OperatorFunction<T, NonUndefined<C>>;
/**
* @internal
*/
export declare function stateful<T, A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): OperatorFunction<T, NonUndefined<D>>;
/**
* @internal
*/
export declare function stateful<T, A, B, C, D, E>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): OperatorFunction<T, NonUndefined<E>>;
//# sourceMappingURL=stateful.d.ts.map