Skip to content

Latest commit

 

History

History
282 lines (172 loc) · 5.85 KB

ianymodeltype.md

File metadata and controls

282 lines (172 loc) · 5.85 KB

mobx-state-tree > IAnyModelType

Interface: IAnyModelType

Any model type.

Hierarchy

IModelType<any, any, any, any>

↳ IAnyModelType

Index

Properties

Methods


Properties

name

● name: string

Friendly type name.


properties

● properties: any


Methods

actions

actions<A>(fn: function): IModelType<any, any & A, any, any>

Type parameters:

A : ModelActions

Parameters:

Name Type
fn function

Returns: IModelType<any, any & A, any, any>


create

create(...args: CreateParams<ModelCreationType2<any, any>>): STNValue<ModelInstanceType<any, any>, this>

create(snapshot: ModelCreationType2<any, any>, env?: any): STNValue<ModelInstanceType<any, any>, this>

Parameters:

Name Type
Rest args CreateParams<ModelCreationType2<any, any>>

Returns: STNValue<ModelInstanceType<any, any>, this>

Creates an instance for the type given an snapshot input.

Parameters:

Name Type
snapshot ModelCreationType2<any, any>
Optional env any

Returns: STNValue<ModelInstanceType<any, any>, this> An instance of that type.


describe

describe(): string

Gets the textual representation of the type as a string.

Returns: string


extend

extend<A,V,VS>(fn: function): IModelType<any, any & A & V & VS, any, any>

Type parameters:

A : ModelActions

V : Object

VS : Object

Parameters:

Name Type
fn function

Returns: IModelType<any, any & A & V & VS, any, any>


is

is(thing: any): boolean

Checks if a given snapshot / instance is of the given type.

Parameters:

Name Type Description
thing any Snapshot or instance to be checked.

Returns: boolean true if the value is of the current type, false otherwise.


named

named(newName: string): IModelType<any, any, any, any>

Parameters:

Name Type
newName string

Returns: IModelType<any, any, any, any>


postProcessSnapshot

postProcessSnapshot<NewS>(fn: function): IModelType<any, any, any, NewS>

deprecated: See types.snapshotProcessor

Type parameters:

NewS

Parameters:

Name Type
fn function

Returns: IModelType<any, any, any, NewS>


preProcessSnapshot

preProcessSnapshot<NewC>(fn: function): IModelType<any, any, NewC, any>

deprecated: See types.snapshotProcessor

Type parameters:

NewC

Parameters:

Name Type
fn function

Returns: IModelType<any, any, NewC, any>


props

props<PROPS2>(props: PROPS2): IModelType<any & ModelPropertiesDeclarationToProperties<PROPS2>, any, any, any>

Type parameters:

PROPS2 : ModelPropertiesDeclaration

Parameters:

Name Type
props PROPS2

Returns: IModelType<any & ModelPropertiesDeclarationToProperties<PROPS2>, any, any, any>


validate

validate(thing: ModelCreationType2<any, any>, context: IValidationContext): IValidationResult

Run's the type's typechecker on the given value with the given validation context.

Parameters:

Name Type Description
thing ModelCreationType2<any, any> Value to be checked, either a snapshot or an instance.
context IValidationContext Validation context, an array of { subpaths, subtypes } that should be validated

Returns: IValidationResult The validation result, an array with the list of validation errors.


views

views<V>(fn: function): IModelType<any, any & V, any, any>

Type parameters:

V : Object

Parameters:

Name Type
fn function

Returns: IModelType<any, any & V, any, any>


volatile

volatile<TP>(fn: function): IModelType<any, any & TP, any, any>

Type parameters:

TP : object

Parameters:

Name Type
fn function

Returns: IModelType<any, any & TP, any, any>