1 | import { ISimpleType } from "../../internal";
|
2 | /**
|
3 | * `types.identifier` - Identifiers are used to make references, lifecycle events and reconciling works.
|
4 | * Inside a state tree, for each type can exist only one instance for each given identifier.
|
5 | * For example there couldn't be 2 instances of user with id 1. If you need more, consider using references.
|
6 | * Identifier can be used only as type property of a model.
|
7 | * This type accepts as parameter the value type of the identifier field that can be either string or number.
|
8 | *
|
9 | * Example:
|
10 | * ```ts
|
11 | * const Todo = types.model("Todo", {
|
12 | * id: types.identifier,
|
13 | * title: types.string
|
14 | * })
|
15 | * ```
|
16 | *
|
17 | * @returns
|
18 | */
|
19 | export declare const identifier: ISimpleType<string>;
|
20 | /**
|
21 | * `types.identifierNumber` - Similar to `types.identifier`. This one will serialize from / to a number when applying snapshots
|
22 | *
|
23 | * Example:
|
24 | * ```ts
|
25 | * const Todo = types.model("Todo", {
|
26 | * id: types.identifierNumber,
|
27 | * title: types.string
|
28 | * })
|
29 | * ```
|
30 | *
|
31 | * @returns
|
32 | */
|
33 | export declare const identifierNumber: ISimpleType<number>;
|
34 | /**
|
35 | * Returns if a given value represents an identifier type.
|
36 | *
|
37 | * @param type
|
38 | * @returns
|
39 | */
|
40 | export declare function isIdentifierType<IT extends typeof identifier | typeof identifierNumber>(type: IT): type is IT;
|
41 | /**
|
42 | * Valid types for identifiers.
|
43 | */
|
44 | export declare type ReferenceIdentifier = string | number;
|