Options
All
  • Public
  • Public/Protected
  • All
Menu

mobx-keystone

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

AbstractModelClass<M>: abstract new (initialData: any) => M

Type parameters

Type declaration

    • abstract new (initialData: any): M
    • Extracts the instance type of an abstract model class.

      Parameters

      • initialData: any

      Returns M

ActionMiddlewareDisposer: () => void

Type declaration

    • (): void
    • The disposer of an action middleware.

      Returns void

AnyModelProp: ModelProp<any, any, any, any, any, any, any, any, any>

Any model property.

AnyNonValueType: ModelClass<AnyModel> | StringConstructor | NumberConstructor | BigIntConstructor | BooleanConstructor | AnyStandardType
AnyStandardType: IdentityType<any> | ModelType<any> | ArrayType<any> | ObjectType<any> | RecordType<any> | ObjectTypeFunction
AnyType: null | undefined | AnyNonValueType
DataModelClassDeclaration<BaseModelClass, ModelInterface>: BaseModelClass & ((...args: any[]) => ModelInterface)

A data model class declaration, made of a base model and the model interface.

Type parameters

  • BaseModelClass

  • ModelInterface

ExtractModelIdProp<TProps>: { [ K in keyof TProps]: TProps[K]["_internal"]["$isId"] extends true ? K : never }[keyof TProps]

Extract the model id property from the model props.

Type parameters

FromSnapshotDefaultType<TProps>: ModelPropsToSnapshotCreationData<TProps>

The default type used by fromSnapshot before processors are applied.

Type parameters

MaybeOptionalModelProp<TPropValue>: ModelProp<TPropValue, TPropValue, TPropValue, TPropValue, IsOptionalValue<TPropValue, never, string>>

A model prop that maybe / maybe not is optional, depending on if the value can take undefined.

Type parameters

  • TPropValue

ModelClass<M>: { fromSnapshotProcessor?: any; toSnapshotProcessor?: any }

Extracts the instance type of a model class.

Type parameters

Type declaration

  • fromSnapshotProcessor?:function
    • fromSnapshotProcessor(sn: any): any
    • Parameters

      • sn: any

      Returns any

  • toSnapshotProcessor?:function
    • toSnapshotProcessor(sn: any, modelInstance: any): any
    • Parameters

      • sn: any
      • modelInstance: any

      Returns any

ModelClassDeclaration<BaseModelClass, ModelInterface>: BaseModelClass & {}

A model class declaration, made of a base model and the model interface.

Type parameters

  • BaseModelClass

  • ModelInterface

ModelCreationData<M>: ModelPropsToCreationData<ModelPropsOf<M>>

The creation data type of a model.

Type parameters

ModelData<M>: Flatten<M["$"]>

The data type of a model.

Type parameters

ModelFromSnapshot<M>: IsNeverType<M[typeof fromSnapshotOverrideTypeSymbol], ModelPropsToSnapshotCreationData<ModelPropsOf<M>>, M[typeof fromSnapshotOverrideTypeSymbol]> & { $modelType?: string }

The from snapshot type of a model.

deprecated

Use SnapshotInOf instead.

Type parameters

ModelIdProp: ModelProp<string, string | undefined, string, string | undefined, never, true>
ModelIdPropertyName<M>: M[typeof modelIdPropertyNameSymbol]

The model id property name.

Type parameters

ModelPropFromSnapshot<MP>: IsNeverType<MP["_internal"]["$fromSnapshotOverride"], SnapshotInOf<MP["_internal"]["$creationValueType"]>, MP["_internal"]["$fromSnapshotOverride"]>

The snapshot in type of a model property.

Type parameters

ModelPropToSnapshot<MP>: IsNeverType<MP["_internal"]["$toSnapshotOverride"], SnapshotOutOf<MP["_internal"]["$valueType"]>, MP["_internal"]["$toSnapshotOverride"]>

The snapshot out type of a model property.

Type parameters

ModelPropsOf<M>: M[typeof propsTypeSymbol]

The props of a model.

Type parameters

ModelPropsToCreationData<MP>: { [ k in keyof MP]?: MP[k]["_internal"]["$creationValueType"] } & { [ k in RequiredModelProps<MP>]: MP[k]["_internal"]["$creationValueType"] }

Type parameters

ModelPropsToData<MP>: Flatten<{ [ k in keyof MP]: MP[k]["_internal"]["$valueType"] }>

Type parameters

ModelPropsToSetter<MP>: Flatten<{ [ k in keyof MP as MP[k]["_internal"]["$hasSetter"] & `set${Capitalize<k & string>}`]: (value: MP[k]["_internal"]["$transformedValueType"]) => void }>

Type parameters

ModelPropsToSnapshotCreationData<MP>: Flatten<{ [ k in keyof MP]?: ModelPropFromSnapshot<MP[k]> extends infer R ? R : never } & { [ k in { [ K in keyof MP]: IsNeverType<MP[K]["_internal"]["$fromSnapshotOverride"], MP[K]["_internal"]["$isRequired"] & K, IsOptionalValue<MP[K]["_internal"]["$fromSnapshotOverride"], never, K>> }[keyof MP]]: ModelPropFromSnapshot<MP[k]> extends infer R ? R : never }>

Type parameters

ModelPropsToSnapshotData<MP>: Flatten<{ [ k in keyof MP]: ModelPropToSnapshot<MP[k]> extends infer R ? R : never }>

Type parameters

ModelPropsToTransformedCreationData<MP>: { [ k in keyof MP]?: MP[k]["_internal"]["$transformedCreationValueType"] } & { [ k in RequiredModelProps<MP>]: MP[k]["_internal"]["$transformedCreationValueType"] }

Type parameters

ModelPropsToTransformedData<MP>: Flatten<{ [ k in keyof MP]: MP[k]["_internal"]["$transformedValueType"] }>

Type parameters

ModelToSnapshot<M>: IsNeverType<M[typeof toSnapshotOverrideTypeSymbol], ModelPropsToSnapshotData<ModelPropsOf<M>>, M[typeof toSnapshotOverrideTypeSymbol]> & { $modelType?: string }

The to snapshot type of a model.

deprecated

Use SnapshotOutOf instead.

Type parameters

ModelTransformedCreationData<M>: ModelPropsToTransformedCreationData<ModelPropsOf<M>>

The transformed creation data type of a model.

Type parameters

ModelTransformedData<M>: ModelPropsToTransformedData<ModelPropsOf<M>>

The transformed data type of a model.

Type parameters

OnGlobalPatchesListener: (target: object, patches: Patch[], inversePatches: Patch[]) => void

Type declaration

    • (target: object, patches: Patch[], inversePatches: Patch[]): void
    • A function that gets called when a global patch is emitted.

      Parameters

      • target: object
      • patches: Patch[]
      • inversePatches: Patch[]

      Returns void

OnPatchesDisposer: () => void

Type declaration

    • (): void
    • Disposer function to stop listening to patches.

      Returns void

OnPatchesListener: (patches: Patch[], inversePatches: Patch[]) => void

Type declaration

    • A function that gets called when a patch is emitted.

      Parameters

      Returns void

OnSnapshotDisposer: () => void

Type declaration

    • (): void
    • Disposer function for onSnapshot.

      Returns void

OnSnapshotListener<T>: (sn: SnapshotOutOf<T>, prevSn: SnapshotOutOf<T>) => void

Type parameters

  • T

Type declaration

OptionalModelProp<TPropValue>: ModelProp<TPropValue, TPropValue | null | undefined, TPropValue, TPropValue | null | undefined, never>

A model prop that is definitely optional.

Type parameters

  • TPropValue

Path: ReadonlyArray<string | number>

Path from a parent to a child.

PathElement: string | number

Property name (if the parent is an object) or index number (if the parent is an array).

RefIdResolver: (target: object) => string | undefined

Type declaration

    • (target: object): string | undefined
    • Reference ID resolver type.

      Parameters

      • target: object

      Returns string | undefined

RefOnResolvedValueChange<T>: (ref: Ref<T>, newValue: T | undefined, oldValue: T | undefined) => void

Type parameters

  • T: object

Type declaration

    • (ref: Ref<T>, newValue: T | undefined, oldValue: T | undefined): void
    • Type for the callback called when a reference resolved value changes.

      Parameters

      • ref: Ref<T>
      • newValue: T | undefined
      • oldValue: T | undefined

      Returns void

RefResolver<T>: (ref: Ref<T>) => T | undefined

Type parameters

  • T: object

Type declaration

    • (ref: Ref<T>): T | undefined
    • Reference resolver type.

      Parameters

      Returns T | undefined

RequiredModelProps<MP>: { [ K in keyof MP]: MP[K]["_internal"]["$isRequired"] & K }[keyof MP]

Type parameters

SnapshotInOf<T>: T extends ObjectMap<infer V> ? SnapshotInOfObjectMap<V> extends infer R ? R : never : T extends ArraySet<infer V> ? SnapshotInOfArraySet<V> extends infer R ? R : never : T extends AnyModel ? SnapshotInOfModel<T> extends infer R ? R : never : T extends Frozen<any> ? SnapshotInOfFrozen<T> extends infer R ? R : never : T extends object ? SnapshotInOfObject<T> extends infer R ? R : never : T

Type parameters

  • T

SnapshotInOfFrozen<F>: { $frozen: true; data: F["data"] }

Type parameters

Type declaration

  • $frozen: true
  • data: F["data"]
SnapshotInOfModel<M>: ModelFromSnapshot<M>

Type parameters

SnapshotInOfObject<T>: { [ k in keyof T]: SnapshotInOf<T[k]> extends infer R ? R : never }

Type parameters

  • T

SnapshotOutOf<T>: T extends ObjectMap<infer V> ? SnapshotOutOfObjectMap<V> extends infer R ? R : never : T extends ArraySet<infer V> ? SnapshotOutOfArraySet<V> extends infer R ? R : never : T extends AnyModel ? SnapshotOutOfModel<T> extends infer R ? R : never : T extends Frozen<any> ? SnapshotOutOfFrozen<T> extends infer R ? R : never : T extends object ? SnapshotOutOfObject<T> extends infer R ? R : never : T

Type parameters

  • T

SnapshotOutOfFrozen<F>: { $frozen: true; data: F["data"] }

Type parameters

Type declaration

  • $frozen: true
  • data: F["data"]
SnapshotOutOfModel<M>: ModelToSnapshot<M>

Type parameters

SnapshotOutOfObject<T>: { [ k in keyof T]: SnapshotOutOf<T[k]> extends infer R ? R : never }

Type parameters

  • T

ToSnapshotDefaultType<TProps>: ModelPropsToSnapshotData<TProps>

The default type used by getSnapshot before processors are applied.

Type parameters

TypeToData<S>: S extends ObjectTypeFunction ? ObjectType<ReturnType<S>>["$$data"] extends infer R ? R : never : S extends { $$data: infer D } ? D : S extends ModelClass<infer M> ? M : S extends StringConstructor ? string : S extends NumberConstructor ? number : S extends BigIntConstructor ? bigint : S extends BooleanConstructor ? boolean : S extends null ? null : S extends undefined ? undefined : never

Type parameters

  • S

UndoEvent: UndoEventWithoutAttachedState & { attachedState: { afterEvent?: unknown; beforeEvent?: unknown } }

An undo/redo event.

UndoEventWithoutAttachedState: UndoSingleEvent | UndoEventGroup

An undo/redo event without attached state.

WithSandboxCallback<T, R>: (...nodes: T) => boolean | { commit: boolean; return: R }

Type parameters

  • T: readonly [object, ...object[]]

  • R

Type declaration

    • (...nodes: T): boolean | { commit: boolean; return: R }
    • Callback function for SandboxManager.withSandbox.

      Parameters

      • Rest ...nodes: T

      Returns boolean | { commit: boolean; return: R }

WritablePath: (string | number)[]

Path from a parent to a child (writable).

_ComposedCreationData<SuperModel, TProps>: SuperModel extends AnyModel ? ModelPropsToTransformedCreationData<TProps> & ModelTransformedCreationData<SuperModel> : ModelPropsToTransformedCreationData<TProps>

Type parameters

_ComposedData<SuperModel, TProps>: SuperModel extends AnyDataModel ? (ModelPropsToCreationData<TProps> & ModelCreationData<SuperModel>) | (ModelPropsToTransformedCreationData<TProps> & ModelTransformedCreationData<SuperModel>) : ModelPropsToCreationData<TProps> | ModelPropsToTransformedCreationData<TProps>

Type parameters

_ModelId<SuperModel, TProps>: SuperModel extends AnyModel ? ModelIdPropertyName<SuperModel> : ExtractModelIdProp<TProps> & string

Type parameters

Variables

arrayActions: { concat: <T>(array: T[], ...items: ConcatArray<T>[]) => T[]; copyWithin: <T>(array: T[], target: number, start: number, end?: number) => T[]; create: <T>(data: T[]) => T[]; delete: <T>(array: T[], index: number) => boolean; fill: <T>(array: T[], value: T, start?: number, end?: number) => T[]; pop: <T>(array: T[]) => undefined | T; push: <T>(array: T[], ...items: T[]) => number; reverse: <T>(array: T[]) => T[]; set: <T>(array: T[], index: number, value: any) => void; setLength: <T>(array: T[], length: number) => void; shift: <T>(array: T[]) => undefined | T; slice: <T>(array: T[], start?: number, end?: number) => T[]; sort: <T>(array: T[], compareFn?: (a: T, b: T) => number) => T[]; splice: (<T>(array: T[], start: number, deleteCount?: number) => T[]) | (<T>(array: T[], start: number, deleteCount: number, ...items: T[]) => T[]); swap: <T>(array: T[], index1: number, index2: number) => boolean; unshift: <T>(array: T[], ...items: T[]) => number } = ...

Type declaration

  • concat: <T>(array: T[], ...items: ConcatArray<T>[]) => T[]
      • <T>(array: T[], ...items: ConcatArray<T>[]): T[]
      • Type parameters

        • T

        Parameters

        • array: T[]
        • Rest ...items: ConcatArray<T>[]

        Returns T[]

  • copyWithin: <T>(array: T[], target: number, start: number, end?: number) => T[]
      • <T>(array: T[], target: number, start: number, end?: number): T[]
      • Type parameters

        • T

        Parameters

        • array: T[]
        • target: number
        • start: number
        • Optional end: number

        Returns T[]

  • create: <T>(data: T[]) => T[]
      • <T>(data: T[]): T[]
      • Type parameters

        • T

        Parameters

        • data: T[]

        Returns T[]

  • delete: <T>(array: T[], index: number) => boolean
      • <T>(array: T[], index: number): boolean
      • Type parameters

        • T

        Parameters

        • array: T[]
        • index: number

        Returns boolean

  • fill: <T>(array: T[], value: T, start?: number, end?: number) => T[]
      • <T>(array: T[], value: T, start?: number, end?: number): T[]
      • Type parameters

        • T

        Parameters

        • array: T[]
        • value: T
        • Optional start: number
        • Optional end: number

        Returns T[]

  • pop: <T>(array: T[]) => undefined | T
      • <T>(array: T[]): undefined | T
      • Type parameters

        • T

        Parameters

        • array: T[]

        Returns undefined | T

  • push: <T>(array: T[], ...items: T[]) => number
      • <T>(array: T[], ...items: T[]): number
      • Type parameters

        • T

        Parameters

        • array: T[]
        • Rest ...items: T[]

        Returns number

  • reverse: <T>(array: T[]) => T[]
      • <T>(array: T[]): T[]
      • Type parameters

        • T

        Parameters

        • array: T[]

        Returns T[]

  • set: <T>(array: T[], index: number, value: any) => void
      • <T>(array: T[], index: number, value: any): void
      • Type parameters

        • T

        Parameters

        • array: T[]
        • index: number
        • value: any

        Returns void

  • setLength: <T>(array: T[], length: number) => void
      • <T>(array: T[], length: number): void
      • Type parameters

        • T

        Parameters

        • array: T[]
        • length: number

        Returns void

  • shift: <T>(array: T[]) => undefined | T
      • <T>(array: T[]): undefined | T
      • Type parameters

        • T

        Parameters

        • array: T[]

        Returns undefined | T

  • slice: <T>(array: T[], start?: number, end?: number) => T[]
      • <T>(array: T[], start?: number, end?: number): T[]
      • Type parameters

        • T

        Parameters

        • array: T[]
        • Optional start: number
        • Optional end: number

        Returns T[]

  • sort: <T>(array: T[], compareFn?: (a: T, b: T) => number) => T[]
      • <T>(array: T[], compareFn?: (a: T, b: T) => number): T[]
      • Type parameters

        • T

        Parameters

        • array: T[]
        • Optional compareFn: (a: T, b: T) => number
            • (a: T, b: T): number
            • Parameters

              • a: T
              • b: T

              Returns number

        Returns T[]

  • splice: (<T>(array: T[], start: number, deleteCount?: number) => T[]) | (<T>(array: T[], start: number, deleteCount: number, ...items: T[]) => T[])
  • swap: <T>(array: T[], index1: number, index2: number) => boolean
      • <T>(array: T[], index1: number, index2: number): boolean
      • Type parameters

        • T

        Parameters

        • array: T[]
        • index1: number
        • index2: number

        Returns boolean

  • unshift: <T>(array: T[], ...items: T[]) => number
      • <T>(array: T[], ...items: T[]): number
      • Type parameters

        • T

        Parameters

        • array: T[]
        • Rest ...items: T[]

        Returns number

cannotSerialize: typeof cannotSerialize = ...
idProp: ModelIdProp = ...

A property that will be used as model id, accessible through $modelId. Can only be used in models and there can be only one per model.

modelIdKey: "$modelId" = "$modelId"

Key that serves as proxy to the model property designed as 'idProp' (if any).

modelTypeKey: "$modelType" = "$modelType"

Key where model snapshots will store model type metadata.

objectActions: { assign: <T>(target: T, partialObject: Partial<T>) => void; call: <T, K>(target: T, methodName: K, ...args: T[K] extends (...args: any[]) => any ? Parameters<any[any]> : never) => T[K] extends (...args: any[]) => any ? ReturnType<any[any]> : never; create: <T>(data: T) => T; delete: <T, K>(target: T, key: K) => boolean; set: <T, K>(target: T, key: K, value: T[K]) => void } = ...

Type declaration

  • assign: <T>(target: T, partialObject: Partial<T>) => void
      • <T>(target: T, partialObject: Partial<T>): void
      • Type parameters

        • T: object

        Parameters

        • target: T
        • partialObject: Partial<T>

        Returns void

  • call: <T, K>(target: T, methodName: K, ...args: T[K] extends (...args: any[]) => any ? Parameters<any[any]> : never) => T[K] extends (...args: any[]) => any ? ReturnType<any[any]> : never
      • <T, K>(target: T, methodName: K, ...args: T[K] extends (...args: any[]) => any ? Parameters<any[any]> : never): T[K] extends (...args: any[]) => any ? ReturnType<any[any]> : never
      • Type parameters

        • T: object

        • K: string | number | symbol

        Parameters

        • target: T
        • methodName: K
        • Rest ...args: T[K] extends (...args: any[]) => any ? Parameters<any[any]> : never

        Returns T[K] extends (...args: any[]) => any ? ReturnType<any[any]> : never

  • create: <T>(data: T) => T
      • <T>(data: T): T
      • Type parameters

        • T: object

        Parameters

        • data: T

        Returns T

  • delete: <T, K>(target: T, key: K) => boolean
      • <T, K>(target: T, key: K): boolean
      • Type parameters

        • T: object

        • K: string | number | symbol

        Parameters

        • target: T
        • key: K

        Returns boolean

  • set: <T, K>(target: T, key: K, value: T[K]) => void
      • <T, K>(target: T, key: K, value: T[K]): void
      • Type parameters

        • T: object

        • K: string | number | symbol

        Parameters

        • target: T
        • key: K
        • value: T[K]

        Returns void

observableOptions: { deep: boolean } = ...

Type declaration

  • deep: boolean
reduxActionType: "applyAction" = "applyAction"
types: { array: <T>(itemType: T) => ArrayType<T[]>; arraySet: <T>(valueType: T) => ModelType<ArraySet<TypeToData<T>>>; bigint: IdentityType<bigint>; boolean: IdentityType<boolean>; dataModelData: <M, K>(modelClass: _ClassOrObject<M, K>) => IdentityType<ModelData<K extends M ? M extends AnyDataModel ? M : never : K extends AnyDataModel ? K : never>>; dateString: IdentityType<string>; dateTimestamp: IdentityType<number>; enum: <E>(enumObject: E) => IdentityType<EnumValues<E>>; frozen: <T>(dataType: T) => ModelType<Frozen<TypeToData<T>>>; integer: IdentityType<number>; literal: <T>(literal: T) => IdentityType<T>; maybe: <T>(baseType: T) => T | IdentityType<undefined>; maybeNull: <T>(type: T) => T | IdentityType<null>; model: <M, K>(modelClass: _ClassOrObject<M, K>) => ModelType<K>; nonEmptyString: IdentityType<string>; null: IdentityType<null>; number: IdentityType<number>; object: <T>(objectFunction: T) => T; objectMap: <T>(valueType: T) => ModelType<ObjectMap<TypeToData<T>>>; or: { <T>(dispatcher: (sn: any) => T[number], ...orTypes: T): T[number]; <T>(...orTypes: T): T[number] }; record: <T>(valueType: T) => RecordType<T>; ref: <O>(refConstructor: RefConstructor<O>) => ModelType<Ref<O>>; refinement: <T>(baseType: T, checkFn: (data: TypeToData<T>) => null | boolean | TypeCheckError, typeName?: string) => T; string: IdentityType<string>; tuple: <T>(...itemTypes: T) => ArrayType<T>; unchecked: <T>() => IdentityType<T>; undefined: IdentityType<undefined>; mapArray: any; mapObject: any; setArray: any } = ...

Type declaration

  • array: <T>(itemType: T) => ArrayType<T[]>
      • A type that represents an array of values of a given type.

        Example:

        const numberArrayType = types.array(types.number)
        

        Type parameters

        Parameters

        • itemType: T

          Type of inner items.

        Returns ArrayType<T[]>

  • arraySet: <T>(valueType: T) => ModelType<ArraySet<TypeToData<T>>>
  • bigint: IdentityType<bigint>
  • boolean: IdentityType<boolean>
  • dataModelData: <M, K>(modelClass: _ClassOrObject<M, K>) => IdentityType<ModelData<K extends M ? M extends AnyDataModel ? M : never : K extends AnyDataModel ? K : never>>
      • A type that represents a data model data. The type referenced in the model decorator will be used for type checking.

        Example:

        const someDataModelDataType = types.dataModelData(SomeModel)
        // or for recursive models
        const someDataModelDataType = types.dataModelData<SomeModel>(() => SomeModel)

        Type parameters

        • M = never

          Data model type.

        • K = M

        Parameters

        • modelClass: _ClassOrObject<M, K>

          Model class.

        Returns IdentityType<ModelData<K extends M ? M extends AnyDataModel ? M : never : K extends AnyDataModel ? K : never>>

  • dateString: IdentityType<string>
  • dateTimestamp: IdentityType<number>
  • enum: <E>(enumObject: E) => IdentityType<EnumValues<E>>
      • An enum type, based on a TypeScript alike enum object. Syntactic sugar for types.or(...enum_values.map(types.literal))

        Example:

        enum Color {
        Red = "red",
        Green = "green"
        }

        const colorType = types.enum(Color)

        Type parameters

        • E: EnumLike

          Enum type.

        Parameters

        • enumObject: E

        Returns IdentityType<EnumValues<E>>

  • frozen: <T>(dataType: T) => ModelType<Frozen<TypeToData<T>>>
      • A type that represents frozen data.

        Example:

        const frozenNumberType = types.frozen(types.number)
        const frozenAnyType = types.frozen(types.unchecked<any>())
        const frozenNumberArrayType = types.frozen(types.array(types.number))
        const frozenUncheckedNumberArrayType = types.frozen(types.unchecked<number[]>())

        Type parameters

        Parameters

        • dataType: T

          Type of the frozen data.

        Returns ModelType<Frozen<TypeToData<T>>>

  • integer: IdentityType<number>
  • literal: <T>(literal: T) => IdentityType<T>
      • A type that represents a certain value of a primitive (for example an exact number or string).

        Example

        const hiType = types.literal("hi") // the string with value "hi"
        const number5Type = types.literal(5) // the number with value 5

        Type parameters

        • T: PrimitiveValue

          Literal value type.

        Parameters

        • literal: T

          Literal value.

        Returns IdentityType<T>

  • maybe: <T>(baseType: T) => T | IdentityType<undefined>
      • A type that represents either a type or undefined. Syntactic sugar for types.or(baseType, types.undefined)

        Example:

        const numberOrUndefinedType = types.maybe(types.number)
        

        Type parameters

        Parameters

        • baseType: T

          Type.

        Returns T | IdentityType<undefined>

  • maybeNull: <T>(type: T) => T | IdentityType<null>
      • A type that represents either a type or null. Syntactic sugar for types.or(baseType, types.null)

        • Example:
          const numberOrNullType = types.maybeNull(types.number)
          

        Type parameters

        Parameters

        • type: T

          Type.

        Returns T | IdentityType<null>

  • model: <M, K>(modelClass: _ClassOrObject<M, K>) => ModelType<K>
      • <M, K>(modelClass: _ClassOrObject<M, K>): ModelType<K>
      • A type that represents a model. The type referenced in the model decorator will be used for type checking.

        Example:

        const someModelType = types.model(SomeModel)
        // or for recursive models
        const someModelType = types.model<SomeModel>(() => SomeModel)

        Type parameters

        • M = never

          Model type.

        • K = M

        Parameters

        • modelClass: _ClassOrObject<M, K>

          Model class.

        Returns ModelType<K>

  • nonEmptyString: IdentityType<string>
  • null: IdentityType<null>
  • number: IdentityType<number>
  • object: <T>(objectFunction: T) => T
      • <T>(objectFunction: T): T
      • A type that represents a plain object. Note that the parameter must be a function that returns an object. This is done so objects can support self / cross types.

        Example:

        // notice the ({ ... }), not just { ... }
        const pointType = types.object(() => ({
        x: types.number,
        y: types.number
        }))

        Type parameters

        • T

          Type.

        Parameters

        • objectFunction: T

          Function that generates an object with types.

        Returns T

  • objectMap: <T>(valueType: T) => ModelType<ObjectMap<TypeToData<T>>>
  • or: { <T>(dispatcher: (sn: any) => T[number], ...orTypes: T): T[number]; <T>(...orTypes: T): T[number] }
      • <T>(dispatcher: (sn: any) => T[number], ...orTypes: T): T[number]
      • <T>(...orTypes: T): T[number]
      • A type that represents the union of several other types (a | b | c | ...). Accepts a dispatcher that, given a snapshot, returns the type that snapshot is.

        Type parameters

        Parameters

        • dispatcher: (sn: any) => T[number]

          Function that given a snapshot returns the type.

            • (sn: any): T[number]
            • Parameters

              • sn: any

              Returns T[number]

        • Rest ...orTypes: T

          Possible types.

        Returns T[number]

      • A type that represents the union of several other types (a | b | c | ...).

        Example:

        const booleanOrNumberType = types.or(types.boolean, types.number)
        

        Type parameters

        Parameters

        • Rest ...orTypes: T

          Possible types.

        Returns T[number]

  • record: <T>(valueType: T) => RecordType<T>
      • A type that represents an object-like map, an object with string keys and values all of a same given type.

        Example:

        // { [k: string]: number }
        const numberMapType = types.record(types.number)

        Type parameters

        Parameters

        • valueType: T

          Type of the values of the object-like map.

        Returns RecordType<T>

  • ref: <O>(refConstructor: RefConstructor<O>) => ModelType<Ref<O>>
      • A type that represents a reference to an object or model.

        Example:

        const refToSomeObject = types.ref(SomeObject)
        

        Type parameters

        • O: object

          Object or model type.

        Parameters

        Returns ModelType<Ref<O>>

  • refinement: <T>(baseType: T, checkFn: (data: TypeToData<T>) => null | boolean | TypeCheckError, typeName?: string) => T
      • A refinement over a given type. This allows you to do extra checks over models, ensure numbers are integers, etc.

        Example:

        const integerType = types.refinement(types.number, (n) => {
        return Number.isInteger(n)
        }, "integer")

        const sumModelType = types.refinement(types.model(Sum), (sum) => {
        // imagine that for some reason sum includes a number 'a', a number 'b'
        // and the result

        const rightResult = sum.a + sum.b === sum.result

        // simple mode that will just return that the whole model is incorrect
        return rightResult

        // this will return that the result field is wrong
        return rightResult ? null : new TypeCheckError(["result"], "a+b", sum.result)
        })

        Type parameters

        Parameters

        • baseType: T

          Base type.

        • checkFn: (data: TypeToData<T>) => null | boolean | TypeCheckError

          Function that will receive the data (if it passes the base type check) and return null or false if there were no errors or either a TypeCheckError instance or true if there were.

        • Optional typeName: string

        Returns T

  • string: IdentityType<string>
  • tuple: <T>(...itemTypes: T) => ArrayType<T>
      • A type that represents an tuple of values of a given type.

        Example:

        const stringNumberTupleType = types.tuple(types.string, types.number)
        

        Type parameters

        Parameters

        • Rest ...itemTypes: T

        Returns ArrayType<T>

  • unchecked: <T>() => IdentityType<T>
      • A type that represents a given value that won't be type checked. This is basically a way to bail out of the runtime type checking system.

        Example:

        const uncheckedSomeModel = types.unchecked<SomeModel>()
        const anyType = types.unchecked<any>()
        const customUncheckedType = types.unchecked<(A & B) | C>()

        Type parameters

        • T = never

          Type of the value, or unkown if not given.

        Returns IdentityType<T>

  • undefined: IdentityType<undefined>
  • mapArray:function
  • mapObject:function
    • Type parameters

      Parameters

      • valueType: T

      Returns RecordType<T>

  • setArray:function
    • Type parameters

      Parameters

      • valueType: T

      Returns ArrayType<T[]>

Functions

  • DataModel<TProps, A>(fnModelProps: (...args: A) => TProps): _DataModel<unknown, TProps>
  • DataModel<TProps>(modelProps: TProps): _DataModel<unknown, TProps>
  • Base abstract class for data models.

    Never override the constructor, use onLazyInit or onLazyAttachedToRootStore instead.

    Type parameters

    Parameters

    • fnModelProps: (...args: A) => TProps

      Function that generates model properties.

        • (...args: A): TProps
        • Parameters

          • Rest ...args: A

          Returns TProps

    Returns _DataModel<unknown, TProps>

  • Base abstract class for data models.

    Never override the constructor, use onLazyInit or onLazyAttachedToRootStore instead.

    Type parameters

    Parameters

    • modelProps: TProps

      Model properties.

    Returns _DataModel<unknown, TProps>

  • Base abstract class for data models that extends another model.

    Type parameters

    Parameters

    Returns _DataModel<TModel, TProps>

  • Base abstract class for data models that extends another model.

    Type parameters

    Parameters

    • baseModel: AbstractModelClass<TModel>

      Base model type.

    • modelProps: TProps

      Model properties.

    Returns _DataModel<TModel, TProps>

  • ExtendedModel<TProps, TModel, A, FS, TS>(genFn: (...args: A) => { baseModel: AbstractModelClass<TModel>; props: TProps }, modelOptions?: ModelOptions<TProps, FS, TS>): _Model<TModel, TProps, FS, TS>
  • ExtendedModel<TProps, TModel, FS, TS>(baseModel: AbstractModelClass<TModel>, modelProps: TProps, modelOptions?: ModelOptions<TProps, FS, TS>): _Model<TModel, TProps, FS, TS>
  • Base abstract class for models that extends another model.

    Type parameters

    • TProps: ModelProps

      New model properties type.

    • TModel: AnyModel<TModel>

      Model type.

    • A: []

    • FS = never

    • TS = never

    Parameters

    Returns _Model<TModel, TProps, FS, TS>

  • Base abstract class for models that extends another model.

    Type parameters

    • TProps: ModelProps

      New model properties type.

    • TModel: AnyModel<TModel>

      Model type.

    • FS = never

    • TS = never

    Parameters

    • baseModel: AbstractModelClass<TModel>

      Base model type.

    • modelProps: TProps

      Model properties.

    • Optional modelOptions: ModelOptions<TProps, FS, TS>

      Model options.

    Returns _Model<TModel, TProps, FS, TS>

  • Model<TProps, A, FS, TS>(fnModelProps: (...args: A) => TProps, modelOptions?: ModelOptions<TProps, FS, TS>): _Model<unknown, TProps, FS, TS>
  • Model<TProps, FS, TS>(modelProps: TProps, modelOptions?: ModelOptions<TProps, FS, TS>): _Model<unknown, TProps, FS, TS>
  • Base abstract class for models.

    Never override the constructor, use onInit or onAttachedToRootStore instead.

    Type parameters

    • TProps: ModelProps

      Model properties type.

    • A: []

    • FS = never

    • TS = never

    Parameters

    • fnModelProps: (...args: A) => TProps

      Function that generates model properties.

        • (...args: A): TProps
        • Parameters

          • Rest ...args: A

          Returns TProps

    • Optional modelOptions: ModelOptions<TProps, FS, TS>

      Model options.

    Returns _Model<unknown, TProps, FS, TS>

  • Base abstract class for models.

    Never override the constructor, use onInit or onAttachedToRootStore instead.

    Type parameters

    • TProps: ModelProps

      Model properties type.

    • FS = never

    • TS = never

    Parameters

    • modelProps: TProps

      Model properties.

    • Optional modelOptions: ModelOptions<TProps, FS, TS>

      Model options.

    Returns _Model<unknown, TProps, FS, TS>

  • _async<A, R>(fn: (...args: A) => Generator<any, R, any>): (...args: A) => Promise<R>
  • Tricks the TS compiler into thinking that a model flow generator function can be awaited (is a promise).

    Type parameters

    • A: any[]

      Function arguments.

    • R

      Return value.

    Parameters

    • fn: (...args: A) => Generator<any, R, any>

      Flow function.

        • (...args: A): Generator<any, R, any>
        • Parameters

          • Rest ...args: A

          Returns Generator<any, R, any>

    Returns (...args: A) => Promise<R>

      • (...args: A): Promise<R>
      • Tricks the TS compiler into thinking that a model flow generator function can be awaited (is a promise).

        Parameters

        • Rest ...args: A

        Returns Promise<R>

  • _await<T>(promise: Promise<T>): Generator<Promise<T>, T, unknown>
  • Makes a promise a flow, so it can be awaited with yield*.

    Type parameters

    • T

      Promise return type.

    Parameters

    • promise: Promise<T>

      Promise.

    Returns Generator<Promise<T>, T, unknown>

  • abstractModelClass<T>(type: T): T & Object
  • deprecated

    Should not be needed anymore.

    Tricks TypeScript into accepting abstract classes as a parameter for ExtendedModel. Does nothing in runtime.

    Type parameters

    • T

      Abstract model class type.

    Parameters

    • type: T

      Abstract model class.

    Returns T & Object

  • Transforms an action call into a redux action.

    Parameters

    Returns ReduxAction

    A redux action.

  • Creates an action tracking middleware, which is a simplified version of the standard action middleware.

    Parameters

    Returns ActionMiddlewareDisposer

    The middleware disposer.

  • Adds a global action middleware to be run when an action is performed. It is usually preferable to use onActionMiddleware instead to limit it to a given tree and only to topmost level actions or actionTrackingMiddleware for a simplified middleware.

    Parameters

    Returns ActionMiddlewareDisposer

    A disposer to cancel the middleware. Note that if you don't plan to do an early disposal of the middleware calling this function becomes optional.

  • applyAction<TRet>(subtreeRoot: object, call: ActionCall): TRet
  • Applies (runs) an action over a target object.

    If you intend to apply serialized actions check one of the applySerializedAction methods instead.

    Type parameters

    • TRet = any

    Parameters

    • subtreeRoot: object

      Subtree root target object to run the action over.

    • call: ActionCall

      The action, usually as coming from onActionMiddleware.

    Returns TRet

    The return value of the action, if any.

  • applyDelete<O, K>(node: O, fieldName: K): void
  • Deletes an object field wrapped in an action.

    Type parameters

    • O: object

    • K: string | number | symbol

    Parameters

    • node: O

      Target object.

    • fieldName: K

      Field name.

    Returns void

  • applyMethodCall<O, K, FN>(node: O, methodName: K, ...args: FN extends AnyFunction ? Parameters<FN> : never): FN extends AnyFunction ? ReturnType<FN> : never
  • Calls an object method wrapped in an action.

    Type parameters

    • O: object

    • K: string | number | symbol

    • FN

    Parameters

    • node: O

      Target object.

    • methodName: K

      Method name.

    • Rest ...args: FN extends AnyFunction ? Parameters<FN> : never

    Returns FN extends AnyFunction ? ReturnType<FN> : never

  • applyPatches(node: object, patches: readonly Patch[] | readonly readonly Patch[][], reverse?: boolean): void
  • Applies the given patches to the given target object.

    Parameters

    • node: object

      Target object.

    • patches: readonly Patch[] | readonly readonly Patch[][]

      List of patches to apply.

    • reverse: boolean = false

      Whether patches are applied in reverse order.

    Returns void

  • Applies (runs) a serialized action over a target object. In this mode newly generated / modified model IDs previously tracked by applySerializedActionAndTrackNewModelIds will be synchronized after the action is applied. This means this method is usually used on the client side.

    If you intend to apply non-serialized actions check applyAction instead.

    Type parameters

    • TRet = any

    Parameters

    Returns TRet

    The return value of the action, if any.

  • Applies (runs) a serialized action over a target object. In this mode newly generated / modified model IDs will be tracked so they can be later synchronized when applying it on another machine via applySerializedActionAndSyncNewModelIds. This means this method is usually used on the server side.

    If you intend to apply non-serialized actions check applyAction instead.

    Type parameters

    • TRet = any

    Parameters

    • subtreeRoot: object

      Subtree root target object to run the action over.

    • call: SerializedActionCall

      The serialized action, usually as coming from the server/client.

    Returns { returnValue: TRet; serializedActionCall: SerializedActionCallWithModelIdOverrides }

    The return value of the action, if any, plus a new serialized action with model overrides.

  • applySet<O, K, V>(node: O, fieldName: K, value: V): void
  • Sets an object field wrapped in an action.

    Type parameters

    • O: object

    • K: string | number | symbol

    • V

    Parameters

    • node: O

      Target object.

    • fieldName: K

      Field name.

    • value: V

      Value to set.

    Returns void

  • Applies a full snapshot over an object, reconciling it with the current contents of the object.

    Type parameters

    • T: object

      Object type.

    Parameters

    • node: T

      Target object (model object, object or array).

    • snapshot: SnapshotInOf<T>

      Snapshot to apply.

    Returns void

  • Applies a full snapshot over an object, reconciling it with the current contents of the object.

    Type parameters

    • T: object

      Object type.

    Parameters

    • node: T

      Target object (model object, object or array).

    • snapshot: SnapshotOutOf<T>

      Snapshot to apply.

    Returns void

  • arraySet<V>(values?: null | readonly V[]): ArraySet<V>
  • Creates a new ArraySet model instance.

    Type parameters

    • V

      Value type.

    Parameters

    • Optional values: null | readonly V[]

    Returns ArraySet<V>

  • Type parameters

    • K

    • V

    Returns ModelPropTransform<[K, V][], Map<K, V>>

  • Type parameters

    • T

    Returns ModelPropTransform<T[], Set<T>>

  • asMap<K, V>(array: [K, V][]): ObservableMap<K, V> & { dataObject: [K, V][] }
  • asMap<T>(object: Record<string, T>): ObservableMap<string, T> & { dataObject: Record<string, T> }
  • Wraps an observable object or a tuple array to offer a map like interface.

    Type parameters

    • K

    • V

    Parameters

    • array: [K, V][]

      Array.

    Returns ObservableMap<K, V> & { dataObject: [K, V][] }

  • Wraps an observable object or a tuple array to offer a map like interface.

    Type parameters

    • T

    Parameters

    • object: Record<string, T>

      Object.

    Returns ObservableMap<string, T> & { dataObject: Record<string, T> }

  • Generates a redux compatible store out of a mobx-keystone object.

    Type parameters

    • T: object

      Object type.

    Parameters

    • target: T

      Root object.

    • Rest ...middlewares: ReduxMiddleware<T>[]

      Optional list of redux middlewares.

    Returns ReduxStore<T>

    A redux compatible store.

  • asSet<T>(array: T[]): ObservableSet<T> & { dataObject: typeof array }
  • Wraps an observable array to offer a set like interface.

    Type parameters

    • T

    Parameters

    • array: T[]

    Returns ObservableSet<T> & { dataObject: typeof array }

  • assertIsTreeNode(value: unknown, argName?: string): asserts value is object
  • Asserts a given object is now a tree node, or throws otherwise.

    Parameters

    • value: unknown

      Value to check.

    • argName: string = "argument"

      Argument name, part of the thrown error description.

    Returns asserts value is object

  • Clones an object by doing a fromSnapshot(getSnapshot(value), { generateNewIds: true }).

    Type parameters

    • T: object

      Object type.

    Parameters

    • node: T

      Object to clone.

    • Optional options: Partial<CloneOptions>

    Returns T

    The cloned object.

  • computedTree(target: any, propertyKey: string, descriptor: PropertyDescriptor): void
  • Decorator for turning a computed property into a computed tree which supports tree traversal functions, contexts, references, etc.

    Parameters

    • target: any

      Prototype of the class.

    • propertyKey: string

      Name of the member.

    • descriptor: PropertyDescriptor

      Property descriptor for the member.

    Returns void

  • connectReduxDevTools(remotedevPackage: any, remotedevConnection: any, target: object, options?: { logArgsNearName?: boolean }): void
  • Connects a tree node to a redux dev tools instance.

    Parameters

    • remotedevPackage: any

      The remotedev package (usually the result of require("remoteDev")) (https://www.npmjs.com/package/remotedev).

    • remotedevConnection: any

      The result of a connect method from the remotedev package (usually the result of remoteDev.connectViaExtension(...)).

    • target: object

      Object to use as root.

    • Optional options: { logArgsNearName?: boolean }
      • Optional logArgsNearName?: boolean

    Returns void

  • createContext<T>(): Context<T | undefined>
  • createContext<T>(defaultValue: T): Context<T>
  • Creates a new context with no default value, thus making its default value undefined.

    Type parameters

    • T

      Context value type.

    Returns Context<T | undefined>

  • Creates a new context with a default value.

    Type parameters

    • T

      Context value type.

    Parameters

    • defaultValue: T

    Returns Context<T>

  • Creates a custom ref to an object, which in its snapshot form has an id.

    Type parameters

    • T: object

      Target object type.

    Parameters

    • modelTypeId: string

      Unique model type id.

    • options: CustomRefOptions<T>

      Custom reference options.

    Returns RefConstructor<T>

    A function that allows you to construct that type of custom reference.

  • decoratedModel<M, MC>(name: undefined | string, clazz: MC, decorators: { [ k in string | number | symbol]?: ((...args: any[]) => any) | readonly ((...args: any[]) => any)[] }): MC
  • Marks a class (which MUST inherit from the Model abstract class) as a model and decorates some of its methods/properties.

    Type parameters

    • M

    • MC: new (...ags: any) => M

    Parameters

    • name: undefined | string

      Unique name for the model type. Note that this name must be unique for your whole application, so it is usually a good idea to use some prefix unique to your application domain. If you don't want to assign a name yet (e.g. for a base model) pass undefined.

    • clazz: MC

      Model class.

    • decorators: { [ k in string | number | symbol]?: ((...args: any[]) => any) | readonly ((...args: any[]) => any)[] }

      Decorators.

    Returns MC

  • deepEquals(a: any, b: any): boolean
  • Deeply compares two values.

    Supported values are:

    • Primitives
    • Boxed observables
    • Objects, observable objects
    • Arrays, observable arrays
    • Typed arrays
    • Maps, observable maps
    • Sets, observable sets
    • Tree nodes (optimized by using snapshot comparison internally)

    Note that in the case of models the result will be false if their model IDs are different.

    Parameters

    • a: any

      First value to compare.

    • b: any

      Second value to compare.

    Returns boolean

    true if they are the equivalent, false otherwise.

  • Ensures that an action call is deserialized by mapping the action arguments into its deserialized version by using deserializeActionCallArgument.

    Parameters

    Returns ActionCall

    The deserialized action call.

  • Transforms an action call argument by returning its deserialized equivalent.

    Parameters

    • argValue: SerializedActionCallArgument | JSONPrimitiveValue

      Argument value to be transformed into its deserialized form.

    • Optional targetRoot: object

    Returns any

    The deserialized form of the passed value.

  • detach(node: object): void
  • Detaches a given object from a tree. If the parent is an object / model, detaching will delete the property. If the parent is an array detaching will remove the node by splicing it. If there's no parent it will throw.

    Parameters

    • node: object

      Object to be detached.

    Returns void

  • draft<T>(original: T): Draft<T>
  • Creates a draft copy of a tree node and all its children.

    Type parameters

    • T: object

      Data type.

    Parameters

    • original: T

      Original node.

    Returns Draft<T>

    The draft object.

  • findChildren<T>(root: object, predicate: (node: object) => boolean, options?: { deep?: boolean }): ReadonlySet<T>
  • Iterates through all children and collects them in a set if the given predicate matches.

    Type parameters

    • T: object = any

    Parameters

    • root: object

      Root object to get the matching children from.

    • predicate: (node: object) => boolean

      Function that will be run for every child of the root object.

        • (node: object): boolean
        • Parameters

          • node: object

          Returns boolean

    • Optional options: { deep?: boolean }
      • Optional deep?: boolean

    Returns ReadonlySet<T>

    A readonly observable set with the matching children.

  • findParent<T>(child: object, predicate: (parentNode: object) => boolean, maxDepth?: number): T | undefined
  • Iterates through all the parents (from the nearest until the root) until one of them matches the given predicate. If the predicate is matched it will return the found node. If none is found it will return undefined.

    Type parameters

    • T: object = any

      Parent object type.

    Parameters

    • child: object

      Target object.

    • predicate: (parentNode: object) => boolean

      Function that will be run for every parent of the target object, from immediate parent to the root.

        • (parentNode: object): boolean
        • Parameters

          • parentNode: object

          Returns boolean

    • maxDepth: number = 0

      Max depth, or 0 for infinite.

    Returns T | undefined

  • findParentPath<T>(child: object, predicate: (parentNode: object) => boolean, maxDepth?: number): FoundParentPath<T> | undefined
  • Iterates through all the parents (from the nearest until the root) until one of them matches the given predicate. If the predicate is matched it will return the found node plus the path to get from the parent to the child. If none is found it will return undefined.

    Type parameters

    • T: object = any

      Parent object type.

    Parameters

    • child: object

      Target object.

    • predicate: (parentNode: object) => boolean

      Function that will be run for every parent of the target object, from immediate parent to the root.

        • (parentNode: object): boolean
        • Parameters

          • parentNode: object

          Returns boolean

    • maxDepth: number = 0

      Max depth, or 0 for infinite.

    Returns FoundParentPath<T> | undefined

  • Marks some data as frozen. Frozen data becomes immutable (at least in dev mode), and is not enhanced with capabilities such as getting the parent of the objects (except for the root object), it is not made deeply observable (though the root object is observable by reference), etc. On the other hand, this means it will be much faster to create/access. Use this for big data pieces that are unlikely to change unless all of them change (for example lists of points for a polygon, etc).

    Note that data passed to frozen must be serializable to JSON, this is:

    • primitive, plain object, or array
    • without cycles

    Type parameters

    • T

    Parameters

    Returns Frozen<T>

  • getChildrenObjects(node: object, options?: { deep?: boolean }): ReadonlySet<object>
  • Returns all the children objects (this is, excluding primitives) of an object.

    Parameters

    • node: object

      Object to get the list of children from.

    • Optional options: { deep?: boolean }
      • Optional deep?: boolean

    Returns ReadonlySet<object>

    A readonly observable set with the children.

  • Gets the currently running action context, or undefined if none.

    Returns ActionContext | undefined

  • Returns the associated metadata for a data model instance or class.

    Parameters

    Returns DataModelMetadata

    The associated metadata.

  • Returns the current global config object.

    Returns Readonly<GlobalConfig>

  • Returns the associated metadata for a model instance or class.

    Parameters

    Returns ModelMetadata

    The associated metadata.

  • getModelRefId(target: object): string | undefined
  • Uses a model getRefId() method whenever possible to get a reference ID. If the model does not have an implementation of that method it returns undefined. If the model has an implementation, but that implementation returns anything other than a string it will throw.

    Parameters

    • target: object

      Target object to get the ID from.

    Returns string | undefined

    The string ID or undefined.

  • Returns the sandbox manager of a node, or undefined if none.

    Parameters

    • node: object

      Node to check.

    Returns SandboxManager | undefined

    The sandbox manager of a node, or undefined if none.

  • getParent<T>(value: object): T | undefined
  • Returns the parent object of the target object, or undefined if there's no parent.

    Type parameters

    • T: object = any

      Parent object type.

    Parameters

    • value: object

      Target object.

    Returns T | undefined

  • getParentPath<T>(value: object): ParentPath<T> | undefined
  • Returns the parent of the target plus the path from the parent to the target, or undefined if it has no parent.

    Type parameters

    • T: object = any

      Parent object type.

    Parameters

    • value: object

      Target object.

    Returns ParentPath<T> | undefined

  • getParentToChildPath(fromParent: object, toChild: object): Path | undefined
  • Gets the path to get from a parent to a given child. Returns an empty array if the child is actually the given parent or undefined if the child is not a child of the parent.

    Parameters

    • fromParent: object
    • toChild: object

    Returns Path | undefined

  • getRefsResolvingTo<T>(target: T, refType?: RefConstructor<T>, options?: { updateAllRefsIfNeeded?: boolean }): ObservableSet<Ref<T>>
  • Gets all references that resolve to a given object.

    Type parameters

    • T: object

      Referenced object type.

    Parameters

    • target: T

      Node the references point to.

    • Optional refType: RefConstructor<T>

      Pass it to filter by only references of a given type, or omit / pass undefined to get references of any type.

    • Optional options: { updateAllRefsIfNeeded?: boolean }

      Options.

      • Optional updateAllRefsIfNeeded?: boolean

    Returns ObservableSet<Ref<T>>

    An observable set with all reference objects that point to the given object.

  • getRoot<T>(value: object): T
  • Returns the root of the target object, or itself if the target is a root.

    Type parameters

    • T: object = any

      Root object type.

    Parameters

    • value: object

      Target object.

    Returns T

  • getRootPath<T>(value: object): RootPath<T>
  • Returns the root of the target plus the path from the root to get to the target.

    Type parameters

    • T: object = any

      Root object type.

    Parameters

    • value: object

      Target object.

    Returns RootPath<T>

  • getRootStore<T>(node: object): T | undefined
  • Gets the root store of a given tree child, or undefined if none.

    Type parameters

    • T: object

      Root store type.

    Parameters

    • node: object

      Target to find the root store for.

    Returns T | undefined

  • Retrieves an immutable snapshot for a data structure. Since returned snapshots are immutable they will respect shallow equality, this is, if no changes are made then the snapshot will be kept the same.

    Type parameters

    Parameters

    • type: T
    • nodeOrPrimitive: TypeToData<T>

      Data structure, including primtives.

    Returns SnapshotOutOf<TypeToData<T>>

    The snapshot.

  • Retrieves an immutable snapshot for a data structure. Since returned snapshots are immutable they will respect shallow equality, this is, if no changes are made then the snapshot will be kept the same.

    Type parameters

    • T

      Object type.

    Parameters

    • nodeOrPrimitive: T

      Data structure, including primtives.

    Returns SnapshotOutOf<T>

    The snapshot.

  • Gets the type info of a given type.

    Parameters

    • type: AnyType

      Type to get the info from.

    Returns TypeInfo

    The type info.

  • Returns if a given action name is a built-in action, this is, one of:

    • applyPatches()
    • applySnapshot()
    • detach()

    Parameters

    • actionName: string

      Action name to check.

    Returns actionName is BuiltInAction

    true if it is a built-in action, false otherwise.

  • isChildOfParent(child: object, parent: object): boolean
  • Returns if the target is a "child" of the tree of the given "parent" object.

    Parameters

    • child: object

      Target object.

    • parent: object

      Parent object.

    Returns boolean

  • isComputedTreeNode(node: object): boolean
  • Returns if a given node is a computed tree node.

    Parameters

    • node: object

      Node to check.

    Returns boolean

    true if it is a computed tree node, false otherwise.

  • Checks if an object is a data model instance.

    Parameters

    • model: unknown

    Returns model is AnyDataModel

  • isGlobalUndoRecordingDisabled(): boolean
  • Returns if the undo recording mechanism is currently disabled.

    Returns boolean

    true if it is currently disabled, false otherwise.

  • isHookAction(actionName: string): actionName is HookAction
  • Returns if a given action name corresponds to a hook, this is, one of:

    • onInit() hook
    • onLazyInit() hook
    • onAttachedToRootStore() hook
    • disposer returned by a onAttachedToRootStore() hook

    Parameters

    • actionName: string

      Action name to check.

    Returns actionName is HookAction

    true if it is a hook, false otherwise.

  • isModel(model: unknown): model is AnyModel
  • Checks if an object is a model instance.

    Parameters

    • model: unknown

    Returns model is AnyModel

  • isModelAction(fn: (...args: any[]) => any): boolean
  • Returns if the given function is a model action or not.

    Parameters

    • fn: (...args: any[]) => any

      Function to check.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns boolean

  • isModelDataObject(value: object): boolean
  • Returns if a given object is a model interim data object ($).

    Parameters

    • value: object

      Object to check.

    Returns boolean

    true if it is, false otherwise.

  • isModelFlow(fn: unknown): boolean
  • Returns if the given function is a model flow or not.

    Parameters

    • fn: unknown

      Function to check.

    Returns boolean

  • isParentOfChild(parent: object, child: object): boolean
  • Returns if the target is a "parent" that has in its tree the given "child" object.

    Parameters

    • parent: object

      Target object.

    • child: object

      Child object.

    Returns boolean

  • Checks if a ref object is of a given ref type.

    Type parameters

    • T: object

      Referenced object type.

    Parameters

    Returns ref is Ref<T>

    true if it is of the given type, false otherwise.

  • isRoot(value: object): boolean
  • Returns if a given object is a root object.

    Parameters

    • value: object

      Target object.

    Returns boolean

  • isRootStore(node: object): boolean
  • Checks if a given object is marked as a root store.

    Parameters

    • node: object

      Object.

    Returns boolean

  • isSandboxedNode(node: object): boolean
  • Returns if a given node is a sandboxed node.

    Parameters

    • node: object

      Node to check.

    Returns boolean

    true if it is sandboxed, false

  • isTreeNode(value: unknown): value is object
  • Checks if a given object is now a tree node.

    Parameters

    • value: unknown

      Value to check.

    Returns value is object

    true if it is a tree node, false otherwise.

  • Converts a JSON patch into a patch.

    Parameters

    Returns Patch

    A patch.

  • jsonPointerToPath(jsonPointer: string): Path
  • Converts a JSON pointer into a path.

    Parameters

    • jsonPointer: string

      JSON pointer to convert.

    Returns Path

    Converted path.

  • mapToArray<K, V>(map: Map<K, V>): [K, V][]
  • Converts a map to an array. If the map is a collection wrapper it will return the backed array.

    Type parameters

    • K

    • V

    Parameters

    • map: Map<K, V>

    Returns [K, V][]

  • mapToObject<T>(map: Map<string, T>): Record<string, T>
  • Converts a map to an object. If the map is a collection wrapper it will return the backed object.

    Type parameters

    • T

    Parameters

    • map: Map<string, T>

    Returns Record<string, T>

  • model(name: string): <MC>(clazz: MC) => MC
  • Decorator that marks this class (which MUST inherit from the Model or DataModel abstract classes) as a model.

    Parameters

    • name: string

      Unique name for the model type. Note that this name must be unique for your whole application, so it is usually a good idea to use some prefix unique to your application domain.

    Returns <MC>(clazz: MC) => MC

  • modelAction(target: any, propertyKey: string, baseDescriptor?: PropertyDescriptor): void
  • Decorator that turns a function into a model action.

    Parameters

    • target: any
    • propertyKey: string
    • Optional baseDescriptor: PropertyDescriptor

    Returns void

  • modelClass<T>(type: { prototype: T }): ModelClass<T>
  • Tricks TypeScript into accepting a particular kind of generic class as a parameter for ExtendedModel. Does nothing in runtime.

    Type parameters

    Parameters

    • type: { prototype: T }

      Generic model class.

      • prototype: T

    Returns ModelClass<T>

  • modelFlow(target: any, propertyKey: string, baseDescriptor?: PropertyDescriptor): void
  • Decorator that turns a function generator into a model flow.

    Parameters

    • target: any
    • propertyKey: string
    • Optional baseDescriptor: PropertyDescriptor

    Returns void

  • Add missing model metadata to a model creation snapshot to generate a proper model snapshot. Usually used alongside fromSnapshot.

    Type parameters

    Parameters

    Returns SnapshotInOfModel<M>

    The model snapshot (including metadata).

  • Add missing model metadata to a model output snapshot to generate a proper model snapshot. Usually used alongside applySnapshot.

    Type parameters

    Parameters

    Returns SnapshotOutOfModel<M>

    The model snapshot (including metadata).

  • objectMap<V>(entries?: null | readonly readonly [string, V][]): ObjectMap<V>
  • Creates a new ObjectMap model instance.

    Type parameters

    • V

      Value type.

    Parameters

    • Optional entries: null | readonly readonly [string, V][]

    Returns ObjectMap<V>

  • Type parameters

    • T

    Returns ModelPropTransform<Record<string, T>, Map<string, T>>

  • Attaches an action middleware that invokes a listener for all actions of a given tree. Note that the listener will only be invoked for the topmost level actions, so it won't run for child actions or intermediary flow steps. Also it won't trigger the listener for calls to hooks such as onAttachedToRootStore or its returned disposer.

    Its main use is to keep track of top level actions that can be later replicated via applyAction somewhere else (another machine, etc.).

    There are two kind of possible listeners, onStart and onFinish listeners. onStart listeners are called before the action executes and allow cancellation by returning a new return value (which might be a return or a throw). onFinish listeners are called after the action executes, have access to the action actual return value and allow overriding by returning a new return value (which might be a return or a throw).

    If you want to ensure that the actual action calls are serializable you should use either serializeActionCallArgument over the arguments or serializeActionCall over the whole action before sending the action call over the wire / storing them .

    Parameters

    Returns ActionMiddlewareDisposer

    The middleware disposer.

  • onChildAttachedTo(target: () => object, fn: (child: object) => void | (() => void), options?: { deep?: boolean; fireForCurrentChildren?: boolean }): (runDetachDisposers: boolean) => void
  • Runs a callback everytime a new object is attached to a given node. The callback can optionally return a disposer which will be run when the child is detached.

    The optional options parameter accepts and object with the following options:

    • deep: boolean (default: false) - true if the callback should be run for all children deeply or false if it it should only run for shallow children.
    • fireForCurrentChildren: boolean (default: true) - true if the callback should be immediately called for currently attached children, false if only for future attachments.

    Returns a disposer, which has a boolean parameter which should be true if pending detachment callbacks should be run or false otherwise.

    Parameters

    • target: () => object

      Function that returns the object whose children should be tracked.

        • (): object
        • Returns object

    • fn: (child: object) => void | (() => void)

      Callback called when a child is attached to the target object.

        • (child: object): void | (() => void)
        • Parameters

          • child: object

          Returns void | (() => void)

    • Optional options: { deep?: boolean; fireForCurrentChildren?: boolean }
      • Optional deep?: boolean
      • Optional fireForCurrentChildren?: boolean

    Returns (runDetachDisposers: boolean) => void

      • (runDetachDisposers: boolean): void
      • Runs a callback everytime a new object is attached to a given node. The callback can optionally return a disposer which will be run when the child is detached.

        The optional options parameter accepts and object with the following options:

        • deep: boolean (default: false) - true if the callback should be run for all children deeply or false if it it should only run for shallow children.
        • fireForCurrentChildren: boolean (default: true) - true if the callback should be immediately called for currently attached children, false if only for future attachments.

        Returns a disposer, which has a boolean parameter which should be true if pending detachment callbacks should be run or false otherwise.

        Parameters

        • runDetachDisposers: boolean

        Returns void

  • Adds a listener that will be called every time a patch is generated anywhere. Usually prefer using onPatches.

    Parameters

    • listener: OnGlobalPatchesListener

      The listener function that will be called everytime a patch is generated anywhere.

    Returns OnPatchesDisposer

    A disposer to stop listening to patches.

  • Adds a listener that will be called every time a patch is generated for the tree of the given target object.

    Parameters

    • subtreeRoot: object

      Subtree root object of the patch listener.

    • listener: OnPatchesListener

      The listener function that will be called everytime a patch is generated for the object or its children.

    Returns OnPatchesDisposer

    A disposer to stop listening to patches.

  • Adds a reaction that will trigger every time an snapshot changes.

    Type parameters

    • T: object

      Object type.

    Parameters

    • nodeOrFn: T | (() => T)

      Object to get the snapshot from or a function to get it.

    • listener: OnSnapshotListener<T>

      Function that will be triggered when the snapshot changes.

    Returns OnSnapshotDisposer

    A disposer.

  • Creates a patch recorder.

    Parameters

    Returns PatchRecorder

    The patch recorder.

  • Convert a patch into a JSON patch.

    Parameters

    Returns JsonPatch

    A JSON patch.

  • pathToJsonPointer(path: Path): string
  • Converts a path into a JSON pointer.

    Parameters

    • path: Path

      Path to convert.

    Returns string

    Converted JSON pointer.

  • Defines a model property, with an optional function to generate a default value if the input snapshot / model creation data is null or undefined.

    Example:

    x: prop(() => 10) // an optional number, with a default value of 10
    x: prop<number[]>(() => []) // an optional number array, with a default empty array

    Type parameters

    • TValue

      Value type.

    Parameters

    • defaultFn: () => TValue

      Default value generator function.

        • (): TValue
        • Returns TValue

    Returns OptionalModelProp<TValue>

  • Defines a model property, with an optional default value if the input snapshot / model creation data is null or undefined. You should only use this with primitive values and never with object values (array, model, object, etc).

    Example:

    x: prop(10) // an optional number, with a default value of 10
    

    Type parameters

    • TValue

      Value type.

    Parameters

    • defaultValue: Exclude<TValue, object>

      Default primitive value.

    Returns OptionalModelProp<TValue>

  • Defines a model property with no default value.

    Example:

    x: prop<number>() // a required number
    x: prop<number | undefined>() // an optional number, which defaults to undefined

    Type parameters

    • TValue

      Value type.

    Returns MaybeOptionalModelProp<TValue>

  • Attaches an action middleware that will throw when any action is started over the node or any of the child nodes, thus effectively making the subtree readonly.

    It will return an object with a dispose function to remove the middleware and a allowWrite function that will allow actions to be started inside the provided code block.

    Example:

    // given a model instance named todo
    const { dispose, allowWrite } = readonlyMiddleware(todo)

    // this will throw
    todo.setDone(false)
    await todo.setDoneAsync(false)

    // this will work
    allowWrite(() => todo.setDone(false))
    // note: for async always use one action invocation per allowWrite!
    await allowWrite(() => todo.setDoneAsync(false))

    Parameters

    • subtreeRoot: object

      Subtree root target object.

    Returns ReadonlyMiddlewareReturn

    An object with the middleware disposer (dispose) and a allowWrite function.

  • Registers a new action call argument serializers. Serializers are called in the inverse order they are registered, meaning the latest one registered will be called first.

    Parameters

    Returns () => void

    A disposer to unregister the serializer.

      • (): void
      • Registers a new action call argument serializers. Serializers are called in the inverse order they are registered, meaning the latest one registered will be called first.

        Returns void

        A disposer to unregister the serializer.

  • registerRootStore<T>(node: T): T
  • Registers a model / tree node object as a root store tree. Marking a model object as a root store tree serves several purposes:

    • It allows the onAttachedToRootStore hook (plus disposer) to be invoked on models once they become part of this tree. These hooks can be used for example to attach effects and serve as some sort of initialization.
    • It allows auto detachable references to work properly.

    Type parameters

    • T: object

      Object type.

    Parameters

    • node: T

      Node object to register as root store.

    Returns T

    The same model object that was passed.

  • resolveId<T>(root: object, id: string, getId?: RefIdResolver): T | undefined
  • Resolves a node given its ID.

    Type parameters

    • T: object

      Target object type.

    Parameters

    • root: object

      Node where to start the search. The search will be done on it and all its children.

    • id: string

      ID to search for.

    • getId: RefIdResolver = getModelRefId

      Function that will be used to get the ID from an object (getModelRefId by default).

    Returns T | undefined

    The node found or undefined if none.

  • resolvePath<T>(pathRootObject: object, path: Path): { resolved: true; value: T } | { resolved: false; value?: undefined }
  • Tries to resolve a path from an object.

    Type parameters

    • T = any

      Returned value type.

    Parameters

    • pathRootObject: object

      Object that serves as path root.

    • path: Path

      Path as an string or number array.

    Returns { resolved: true; value: T } | { resolved: false; value?: undefined }

    An object with { resolved: true, value: T } or { resolved: false }.

  • Creates a root ref to an object, which in its snapshot form has an id. A root ref will only be able to resolve references as long as both the Ref and the referenced object share a common root.

    Type parameters

    • T: object

      Target object type.

    Parameters

    • modelTypeId: string

      Unique model type id.

    • Optional options: RootRefOptions<T>

    Returns RefConstructor<T>

    A function that allows you to construct that type of root reference.

  • runUnprotected<T>(name: string, fn: () => T): T
  • runUnprotected<T>(fn: () => T): T
  • Runs a block in unprocted mode, as if it were run inside a model action. Consider using a proper model action instead since these kind of actions are not recorded.

    Type parameters

    • T

      Return type.

    Parameters

    • name: string

      Mobx action name.

    • fn: () => T

      Action block.

        • (): T
        • Returns T

    Returns T

  • Runs a block in unprocted mode, as if it were run inside a model action. Consider using a proper model action instead since these kind of actions are not recorded.

    Type parameters

    • T

      Return type.

    Parameters

    • fn: () => T

      Action block.

        • (): T
        • Returns T

    Returns T

  • Creates a sandbox.

    Parameters

    • subtreeRoot: object

      Subtree root target object.

    Returns SandboxManager

    A SandboxManager which allows you to manage the sandbox operations and dispose of the sandbox.

  • Ensures that an action call is serializable by mapping the action arguments into its serializable version by using serializeActionCallArgument.

    Parameters

    • actionCall: ActionCall

      Action call to convert.

    • Optional targetRoot: object

    Returns SerializedActionCall

    The serializable action call.

  • Transforms an action call argument by returning a SerializedActionCallArgument. The following are supported out of the box:

    • Primitives.
    • Nodes that are under the same root node as the target root (when provided) will be serialized as a path.
    • Nodes that are not under the same root node as the target root will be serialized as their snapshot.
    • Arrays (observable or not).
    • Dates.
    • Maps (observable or not).
    • Sets (observable or not).
    • Plain objects (observable or not).

    If the value cannot be serialized it will throw an exception.

    Parameters

    • argValue: any

      Argument value to be transformed into its serializable form.

    • Optional targetRoot: object

    Returns SerializedActionCallArgument | JSONPrimitiveValue

    The serializable form of the passed value.

  • Partially sets the current global config.

    Parameters

    • config: Partial<GlobalConfig>

      Partial object with the new configurations. Options not included in the object won't be changed.

    Returns void

  • setToArray<T>(set: Set<T>): T[]
  • Converts a set to an array. If the set is a collection wrapper it will return the backed array.

    Type parameters

    • T

    Parameters

    • set: Set<T>

    Returns T[]

  • Simplifies an action context by converting an async call hierarchy into a simpler one.

    Parameters

    Returns SimpleActionContext

    Simplified action context.

  • standaloneAction<FN>(actionName: string, fn: FN): FN
  • Creates a standalone action. A standalone action must always take an existing tree node as first argument.

    Type parameters

    • FN: (target: any, ...args: any[]) => any

    Parameters

    • actionName: string

      Unique action name.

    • fn: FN

      Function.

    Returns FN

    The function as an standalone action.

  • standaloneFlow<FN>(actionName: string, fn: FN): FN
  • Creates a standalone flow. A standalone flow must always take an existing tree node as first argument.

    Type parameters

    • FN: (target: any, ...args: any[]) => Generator<any, any, any>

    Parameters

    • actionName: string

      Unique action name.

    • fn: FN

      Function.

    Returns FN

    The function as an standalone flow.

  • Defines a string model property with a default value. Equivalent to tProp(types.string, defaultValue).

    Example:

    x: tProp("foo") // an optional string that will take the value `"foo"` when undefined.
    

    Parameters

    • defaultValue: string

      Default value.

    Returns OptionalModelProp<string>

  • Defines a number model property with a default value. Equivalent to tProp(types.number, defaultValue).

    Example:

    x: tProp(42) // an optional number that will take the value `42` when undefined.
    

    Parameters

    • defaultValue: number

      Default value.

    Returns OptionalModelProp<number>

  • Defines a boolean model property with a default value. Equivalent to tProp(types.boolean, defaultValue).

    Example:

    x: tProp(true) // an optional boolean that will take the value `true` when undefined.
    

    Parameters

    • defaultValue: boolean

      Default value.

    Returns OptionalModelProp<boolean>

  • Defines a model property, with an optional function to generate a default value if the input snapshot / model creation data is null or undefined and with an associated type checker.

    Example:

    x: tProp(types.number, () => 10) // an optional number, with a default value of 10
    x: tProp(types.array(types.number), () => []) // an optional number array, with a default empty array

    Type parameters

    Parameters

    Returns OptionalModelProp<TypeToData<TType>>

  • Defines a model property, with an optional default value if the input snapshot / model creation data is null or undefined and with an associated type checker. You should only use this with primitive values and never with object values (array, model, object, etc).

    Example:

    x: tProp(types.number, 10) // an optional number, with a default value of 10
    

    Type parameters

    Parameters

    • type: TType

      Type checker.

    • defaultValue: TypeToData<TType>

      Default value generator function.

    Returns OptionalModelProp<TypeToData<TType>>

  • Defines a model property with no default value and an associated type checker.

    Example:

    x: tProp(types.number) // a required number
    x: tProp(types.maybe(types.number)) // an optional number, which defaults to undefined

    Type parameters

    Parameters

    • type: TType

      Type checker.

    Returns MaybeOptionalModelProp<TypeToData<TType>>

  • tag<Target, TagData>(tagDataConstructor: (target: Target) => TagData): { for: any }
  • Creates a tag data accessor for a target object of a certain type. Tag data will be lazy created on access and reused for the same target object.

    Type parameters

    • Target: object

      Target type.

    • TagData

      Tag data type.

    Parameters

    • tagDataConstructor: (target: Target) => TagData

      Function that will be called the first time the tag for a given object is requested.

        • (target: Target): TagData
        • Parameters

          • target: Target

          Returns TagData

    Returns { for: any }

    The tag data associated with the target object.

    • for:function
      • for(target: Target): TagData
      • Parameters

        • target: Target

        Returns TagData

  • toTreeNode<TType, V>(type: TType, value: V): V
  • toTreeNode<T>(value: T): T
  • Turns an object (array, plain object) into a tree node, which then can accept calls to getParent, getSnapshot, etc. If a tree node is passed it will return the passed argument directly. Additionally this method will use the type passed to check the value conforms to the type when model auto type checking is enabled.

    Type parameters

    Parameters

    • type: TType

      Type checker.

    • value: V

      Object to turn into a tree node.

    Returns V

    The object as a tree node.

  • Turns an object (array, plain object) into a tree node, which then can accept calls to getParent, getSnapshot, etc. If a tree node is passed it will return the passed argument directly.

    Type parameters

    • T: object

    Parameters

    • value: T

      Object to turn into a tree node.

    Returns T

    The object as a tree node.

  • transaction(target: any, propertyKey: string): void
  • Transaction middleware as a decorator.

    Parameters

    • target: any
    • propertyKey: string

    Returns void

  • Creates a transaction middleware, which reverts changes made by an action / child actions when the root action throws an exception by applying inverse patches.

    Type parameters

    Parameters

    • target: { actionName: keyof M; model: M }

      Object with the root target model object (model) and root action name (actionName).

      • actionName: keyof M
      • model: M

    Returns ActionMiddlewareDisposer

    The middleware disposer.

  • Checks if a value conforms to a given type.

    typename

    T Type.

    Type parameters

    Parameters

    • type: T

      Type to check for.

    • value: TypeToData<T>

      Value to check.

    Returns TypeCheckError | null

    A TypeError if the check fails or null if no error.

  • Creates an undo middleware.

    Type parameters

    • S

    Parameters

    • subtreeRoot: object

      Subtree root target object.

    • Optional store: UndoStore

      Optional UndoStore where to store the undo/redo queues. Use this if you want to store such queues somewhere in your models. If none is provided it will reside in memory.

    • Optional options: UndoMiddlewareOptions<S>

      Extra options, such as how to save / restore certain snapshot of the state to be restored when undoing/redoing.

    Returns UndoManager

    An UndoManager which allows you to do the manage the undo/redo operations and dispose of the middleware.

  • unregisterRootStore(node: object): void
  • Unregisters an object to mark it as no longer a root store.

    Parameters

    • node: object

      Node object to unregister as root store.

    Returns void

  • walkTree<T>(target: object, predicate: (node: object) => undefined | T, mode: WalkTreeMode): T | undefined
  • Walks a tree, running the predicate function for each node. If the predicate function returns something other than undefined, then the walk will be stopped and the function will return the returned value.

    Type parameters

    • T = void

      Returned object type, defaults to void.

    Parameters

    • target: object

      Subtree root object.

    • predicate: (node: object) => undefined | T

      Function that will be run for each node of the tree.

        • (node: object): undefined | T
        • Parameters

          • node: object

          Returns undefined | T

    • mode: WalkTreeMode

      Mode to walk the tree, as defined in WalkTreeMode.

    Returns T | undefined

  • withoutUndo<T>(fn: () => T): T
  • Globally skips the undo recording mechanism for the code block that gets run synchronously inside. Consider using the withoutUndo method of a particular UndoManager instead.

    Type parameters

    • T

      Code block return type.

    Parameters

    • fn: () => T

      Code block to run.

        • (): T
        • Returns T

    Returns T

    The value returned by the code block.

Generated using TypeDoc