import { IEnhancer } from "./modifiers"; import { Lambda } from "../utils/utils"; import { IInterceptable, IInterceptor } from "./intercept-utils"; import { IListenable } from "./listen-utils"; import { Iterator } from "../utils/iterable"; /** * Map as defined by Typescript's lib.es2015.collection.d.ts * * Imported here to not require consumers to have these libs enabled in their tsconfig if not actually using maps */ export interface IMap { clear(): void; delete(key: K): boolean; forEach(callbackfn: (value: V, index: K, map: IMap) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; set(key: K, value?: V): this; readonly size: number; } export interface IKeyValueMap { [key: string]: V; } export declare type IMapEntry = [string, V]; export declare type IMapEntries = IMapEntry[]; export declare type IMapChange = IMapChangeUpdate | IMapChangeAdd | IMapChangeDelete; export interface IMapChangeBase { object: ObservableMap; name: string; } export interface IMapChangeUpdate extends IMapChangeBase { type: "update"; newValue: T; oldValue: T; } export interface IMapChangeAdd extends IMapChangeBase { type: "add"; newValue: T; } export interface IMapChangeDelete extends IMapChangeBase { type: "delete"; oldValue: T; } export interface IMapWillChange { object: ObservableMap; type: "update" | "add" | "delete"; name: string; newValue?: T; } export declare type IObservableMapInitialValues = IMapEntries | IKeyValueMap | IMap; export declare class ObservableMap implements IInterceptable>, IListenable, IMap { enhancer: IEnhancer; name: string; $mobx: {}; private _data; private _hasMap; private _keys; interceptors: null; changeListeners: null; dehancer: any; constructor(initialData?: IObservableMapInitialValues, enhancer?: IEnhancer, name?: string); private _has(key); has(key: string): boolean; set(key: string, value?: V | undefined): this; delete(key: string): boolean; private _updateHasMapEntry(key, value); private _updateValue(name, newValue); private _addValue(name, newValue); get(key: string): V | undefined; private dehanceValue(value); keys(): string[] & Iterator; values(): V[] & Iterator; entries(): IMapEntries & Iterator>; forEach(callback: (value: V, key: string, object: IMap) => void, thisArg?: any): void; /** Merge another object into this object, returns this. */ merge(other: ObservableMap | IKeyValueMap | any): ObservableMap; clear(): void; replace(values: ObservableMap | IKeyValueMap | any): ObservableMap; readonly size: number; /** * Returns a shallow non observable object clone of this map. * Note that the values might still be observable. For a deep clone use mobx.toJS. */ toJS(): IKeyValueMap; toJSON(): IKeyValueMap; private isValidKey(key); private assertValidKey(key); toString(): string; /** * Observes this object. Triggers for the events 'add', 'update' and 'delete'. * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe * for callback details */ observe(listener: (changes: IMapChange) => void, fireImmediately?: boolean): Lambda; intercept(handler: IInterceptor>): Lambda; } export declare function map(initialValues?: IObservableMapInitialValues): ObservableMap; export declare var isObservableMap: (thing: any) => thing is ObservableMap;