@rx-angular/cdk
Version:
@rx-angular/cdk is a Component Development Kit for ergonomic and highly performant angular applications. It helps to to build Large scale applications, UI libs, state management, rendering systems and much more. Furthermore the unique way of mixing reacti
42 lines (41 loc) • 1.36 kB
TypeScript
import { Observable } from 'rxjs';
import { ExtractObservableValue, NotEmpty, ObservableMap } from './model';
/**
* This Observable creation function helps to accumulate an object of key & Observable of values to
* an Observable of objects of key & value.
* This comes in handy if you quickly want to create subsets as objects/state-slices of different Observables.
*
* The resulting Observable filters out undefined values forwards only distinct values and shared the aggregated output.
*
* @example
*
* Default usage:
*
* const object$: Observable<{
* prop1: number,
* prop2: string,
* prop3: string
* }> = accumulateObservables({
* prop1: interval(42),
* prop2: of('lorem'),
* prop3: 'test'
* });
*
* Usage with custom duration selector:
*
* const object$: Observable<{
* prop1: number,
* prop2: string,
* prop3: string
* }> = accumulateObservables({
* prop1: interval(42),
* prop2: of('lorem'),
* prop3: 'test'
* }, timer(0, 20));
*
* @param obj - An object of key & Observable values pairs
* @param durationSelector - An Observable determining the duration for the internal coalescing method
*/
export declare function accumulateObservables<T extends ObservableMap & NotEmpty<T>>(obj: T, durationSelector?: Observable<any>): Observable<{
[K in keyof T]: ExtractObservableValue<T[K]>;
}>;