import { IInterceptor, IKeyValueMap, IMapDidChange, IMapWillChange, Lambda } from "mobx"; import { IAnyType, IType, ExtractCSTWithSTN, IHooksGetter } from "../../internal"; /** @hidden */ export interface IMapType extends IType | undefined, IKeyValueMap, IMSTMap> { hooks(hooks: IHooksGetter>): IMapType; } /** @hidden */ export interface IMSTMap { clear(): void; delete(key: string): boolean; forEach(callbackfn: (value: IT["Type"], key: string, map: this) => void, thisArg?: any): void; get(key: string): IT["Type"] | undefined; has(key: string): boolean; set(key: string, value: ExtractCSTWithSTN): this; readonly size: number; put(value: ExtractCSTWithSTN): IT["Type"]; keys(): IterableIterator; values(): IterableIterator; entries(): IterableIterator<[string, IT["Type"]]>; [Symbol.iterator](): IterableIterator<[string, IT["Type"]]>; /** Merge another object into this map, returns self. */ merge(other: IMSTMap> | IKeyValueMap> | any): this; replace(values: IMSTMap> | IKeyValueMap> | any): this; toJSON(): IKeyValueMap; toString(): string; [Symbol.toStringTag]: "Map"; /** * 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: IMapDidChange) => void, fireImmediately?: boolean): Lambda; intercept(handler: IInterceptor>): Lambda; } /** * `types.map` - Creates a key based collection type who's children are all of a uniform declared type. * If the type stored in a map has an identifier, it is mandatory to store the child under that identifier in the map. * * This type will always produce [observable maps](https://mobx.js.org/api.html#observablemap) * * Example: * ```ts * const Todo = types.model({ * id: types.identifier, * task: types.string * }) * * const TodoStore = types.model({ * todos: types.map(Todo) * }) * * const s = TodoStore.create({ todos: {} }) * unprotect(s) * s.todos.set(17, { task: "Grab coffee", id: 17 }) * s.todos.put({ task: "Grab cookie", id: 18 }) // put will infer key from the identifier * console.log(s.todos.get(17).task) // prints: "Grab coffee" * ``` * * @param subtype * @returns */ export declare function map(subtype: IT): IMapType; /** * Returns if a given value represents a map type. * * @param type * @returns `true` if it is a map type. */ export declare function isMapType(type: IAnyType): type is IMapType;