@obsidize/rx-map
Version:
ES6 Map with rxjs extensions for change detection
36 lines (35 loc) • 1.97 kB
TypeScript
import { ChangeDetectionResult } from '../events/change-detection-event';
import { MapStateChangeEvent } from '../events/map-state-change-event';
export declare type Predicate<V> = (value: V) => boolean;
export declare type PropertySelector<K, V> = (value: V) => K;
export declare function identity<T>(value: T, ..._args: any[]): any;
export declare function isNull(value: any): boolean;
export declare function isUndefined(value: any): boolean;
export declare function isFunction(value: any): boolean;
export declare function isObject(value: any): boolean;
export declare function castArray<T>(v: any): T[];
export declare function mergeObjects(a: any, b: any): any;
export declare function cloneObject(v: any): any;
export declare function deepDifferenceBetween<T>(current: T, previous: T): Partial<T>;
/**
* Evaluates changes between the two given values,
* and constructs a change detection event instance based on the evaluation output.
*
* The output in the "changes" object will consist of all the values that have changed
* when transitioning from 'baseObj' to 'obj', and the plucked values will match the ones in 'obj'.
*/
export declare function detectChanges<T>(current: T, previous: T): ChangeDetectionResult<T>;
/**
* Convenience for running change detection on a map state change event and storing the results in the event.
* This is implemented as an optional utility since change detection might not be necessary in some cases,
* and can be quite expensive to run.
*/
export declare function extractChanges<K, V>(ev: MapStateChangeEvent<K, V>): MapStateChangeEvent<K, V>;
export interface ChangeDetectionAccumulator<T> extends ChangeDetectionResult<T> {
current: T;
previous?: T;
}
/**
* Special variant of change detection that compares against an accumulated state.
*/
export declare function detectAccumulatedChanges<T>(acc: ChangeDetectionAccumulator<T>, current: T): ChangeDetectionAccumulator<T>;