UNPKG

@obsidize/rx-map

Version:

ES6 Map with rxjs extensions for change detection

38 lines (37 loc) 1.87 kB
import { Observable, Subject } from 'rxjs'; import { MapStateChangeEvent, MapStateChangeEventContext, MapStateChangeEventType } from '../events/map-state-change-event'; import { ImmutableMap } from './immutable-map'; /** * Extension of the standard ES6 Map with rxjs change event observables tacked on. */ export declare class RxMap<K, V, T extends Map<K, V> = Map<K, V>> implements Map<K, V> { protected readonly source: T; protected readonly mStateChangeSubject: Subject<MapStateChangeEvent<K, V>>; readonly allChanges: Observable<MapStateChangeEvent<K, V>>; readonly changes: Observable<MapStateChangeEvent<K, V>>; constructor(source: T); /** * Generate an RxMap instance with a standard (mutable) Map store. */ static mutable<K1, V1>(): RxMap<K1, V1, Map<K1, V1>>; /** * Generate an RxMap instance with an immutable backend store. */ static immutable<K1, V1>(): RxMap<K1, V1, ImmutableMap<K1, V1>>; protected emit(type: MapStateChangeEventType, key: K, value?: V, previousValue?: Partial<V>, context?: MapStateChangeEventContext): void; protected emitSet(key: K, value: V, previousValue?: V, context?: MapStateChangeEventContext): void; protected emitDelete(key: K, value: V, context?: MapStateChangeEventContext): void; get size(): number; get [Symbol.toStringTag](): string; [Symbol.iterator](): IterableIterator<[K, V]>; get(key: K): V | undefined; has(key: K): boolean; entries(): IterableIterator<[K, V]>; keys(): IterableIterator<K>; values(): IterableIterator<V>; forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void): void; destroy(): void; clear(): void; delete(key: K, context?: MapStateChangeEventContext): boolean; set(key: K, value: V, context?: MapStateChangeEventContext): this; }