@obsidize/rx-map
Version:
ES6 Map with rxjs extensions for change detection
53 lines (52 loc) • 2.63 kB
TypeScript
import { MonoTypeOperatorFunction, OperatorFunction } from 'rxjs';
import { ChangeDetectionAccumulator, PropertySelector } from './utility';
import { MapStateChangeEvent, MapStateChangeEventType } from '../events/map-state-change-event';
import { EntityPropertyChangeEvent } from '../events/entity-property-change-event';
import { RxEntityMap } from '../maps/rx-entity-map';
/**
* Variant of filter() that uses a Set to increase lookup speed when checking emissions for a single property value.
* NOTE: this variant is top-heavy, and more expensive on smaller value lists; only use this when
* the 'values' collection can become large.
*/
export declare function spreadFilterBy<T, R>(values: T[], extractValue: (emission: R) => T): MonoTypeOperatorFunction<R>;
/**
* filter by map change event types (useful if you only want to watch ADD or UPDATE changes)
*/
export declare function ofType<K, V>(...types: MapStateChangeEventType[]): MonoTypeOperatorFunction<MapStateChangeEvent<K, V>>;
/**
* filter by entity primary key
*/
export declare function forKey<K, V>(key: K): MonoTypeOperatorFunction<MapStateChangeEvent<K, V>>;
/**
* filter by a set of entity primary keys
*/
export declare function forKeyIn<K, V>(keys: K[]): MonoTypeOperatorFunction<MapStateChangeEvent<K, V>>;
/**
* Narrows the scope of raw map change events into property-specific events.
*/
export declare function pluckValueChanges<K, V, T>(selectValue: PropertySelector<T, V>): OperatorFunction<MapStateChangeEvent<K, V>, EntityPropertyChangeEvent<K, T>>;
/**
* map change events to their corresponding entity value
*/
export declare function pluckValue<T>(): OperatorFunction<{
value?: T;
}, T>;
/**
* map change events to their corresponding entity update differences (will be a partial entity object)
*/
export declare function pluckChanges<T>(): OperatorFunction<{
changes?: T;
}, Partial<T>>;
/**
* capture emitted values and store them in the provided map reference by side-effect
*/
export declare function storeEntityIn<K, V>(entityMap: RxEntityMap<K, V>): MonoTypeOperatorFunction<V>;
/**
* capture emitted values and store them in the provided map reference by side-effect
*/
export declare function storeEntityArrayIn<K, V>(entityMap: RxEntityMap<K, V>): MonoTypeOperatorFunction<V[]>;
/**
* Emits change detection diffs between each emission and the one previous of it.
* NOTE: if the detection result type is NO_CHANGE, then the emission will be dropped.
*/
export declare function accumulateChanges<T>(): OperatorFunction<T, ChangeDetectionAccumulator<T>>;