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
25 lines (24 loc) • 1.36 kB
TypeScript
import type { AnyDataModel } from "../dataModel/BaseDataModel";
import type { AnyModel } from "../model/BaseModel";
import { ModelClass } from "../modelShared/BaseModelShared";
/**
* Decorator that marks this class (which MUST inherit from the `Model` or `DataModel` abstract classes)
* as a model.
*
* @param name 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.
*/
export declare const model: (name: string) => <MC extends ModelClass<AnyDataModel | AnyModel>>(clazz: MC) => MC;
/**
* Marks a class (which MUST inherit from the `Model` abstract class)
* as a model and decorates some of its methods/properties.
*
* @param name 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`.
* @param clazz Model class.
* @param decorators Decorators.
*/
export declare function decoratedModel<MC extends ModelClass<AnyModel>>(name: string | undefined, clazz: MC, decorators: {
[k in keyof InstanceType<MC>]?: ((...args: any[]) => any) | ReadonlyArray<(...args: any[]) => any>;
}): MC;