@mocanvas/store · class
declare class RecordType<R extends UnknownRecord, RequiredProps extends keyof R = RecordDataKeys<R>>Describes one kind of record in the store: how to make ids, defaults, validation, and where the record lives (its scope).
Methods · 8
clone(record: R): RShallow-clone a record (props/meta are shared).
constructor(typeName: R["typeName"], config: RecordTypeConfig<R> & {create(properties: RecordCreateProps<R, RequiredProps>): RCreate a new record with defaults applied. A fresh id is generated when none is given.
createId(customUniquePart?: string): IdOf<R>Make an id of this type: ${typeName}:${uniquePart}.
isId(id?: string): id is IdOf<R>isInstance(record?: unknown): record is RparseId(id: IdOf<R>): stringRecover the unique part of an id of this type.
validate(record: unknown, recordBefore?: R): RRun the validator (if any). Throws on invalid input.
Properties · 6
readonly ephemeralKeys: EphemeralKeys<R> | undefinedreadonly ephemeralKeySet: ReadonlySet<string>readonly scope: RecordScopereadonly typeName: R["typeName"]readonly validator: StoreValidator<R> | undefinedwithDefaultProperties<DefaultProps extends RecordDataKeys<R>>(createDefaultProperties: () => Pick<R, DefaultProps>): RecordType<R, Exclude<RequiredProps, DefaultProps>>Return a new RecordType whose create() fills in the given defaults, so
those properties become optional for callers.
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.