UNPKG

mobx-keystone-mindreframer

Version:

A MobX powered state management solution based on data trees with first class support for Typescript, snapshots, patches and much more

56 lines (55 loc) 1.9 kB
import type { ModelClass } from "../modelShared/BaseModelShared"; declare const Ref_base: import("../model/Model")._Model<unknown, { /** * Reference id. */ id: import("..").MaybeOptionalModelProp<string>; } & { $modelId: import("..").ModelProp<string, string, string, true, never>; }>; /** * A reference model base type. * Use `customRef` to create a custom ref constructor. */ export declare abstract class Ref<T extends object> extends Ref_base { protected abstract resolve(): T | undefined; /** * The object this reference points to, or `undefined` if the reference is currently invalid. */ get maybeCurrent(): T | undefined; /** * If the reference is currently valid. */ get isValid(): boolean; /** * The object this reference points to, or throws if invalid. */ get current(): T; /** * Ensures back references for this ref are up to date. * This only needs to be called if you need to get the most up to date * back references while both still inside an action and while the reference * is not a child of the same root than the target. */ abstract forceUpdateBackRefs(): void; } /** * @ignore */ export declare const customRefTypeSymbol: unique symbol; /** A ref constructor for custom refs */ export interface RefConstructor<T extends object> { <TE extends T>(valueOrID: TE | string): Ref<TE>; refClass: ModelClass<Ref<T>>; [customRefTypeSymbol]: T; } /** * Checks if a ref object is of a given ref type. * * @typeparam T Referenced object type. * @param ref Reference object. * @param refType Reference type. * @returns `true` if it is of the given type, false otherwise. */ export declare function isRefOfType<T extends object>(ref: Ref<object>, refType: RefConstructor<T>): ref is Ref<T>; export {};