Skip to content

ReactiveStateSchema

Inherits: Class

Methods

AddBooleanField

lua
function ReactiveStateSchema:AddBooleanField(key, default)
  -> self

Defines a boolean field as part of the schema.

Parameters:

NameTypeDescription
keystringThe key of the new field
defaultbooleanThe default value of the field

Returns:

TypeDescription
self

AddDeferredBooleanField

lua
function ReactiveStateSchema:AddDeferredBooleanField(key)
  -> self

Defines a boolean field as part of the schema which can be nil (and is by default) but is defined with a non-nil assertion for the language server.

Parameters:

NameTypeDescription
keystringThe key of the new field

Returns:

TypeDescription
self

AddDeferredClassField

lua
function ReactiveStateSchema:AddDeferredClassField(key, class)
  -> self

Defines an optional class field as part of the schema which can be nil (and is by default) but is defined with a non-nil assertion for the language server.

Parameters:

NameTypeDescription
keystringThe key of the new field
classT | TThe class or name of the class (subclasses are not permitted in the later case)

Returns:

TypeDescription
self

AddDeferredEnumField

lua
function ReactiveStateSchema:AddDeferredEnumField(key, enumType)
  -> self

Defines an enum field field as part of the schema which can be nil (and is by default) but is defined with a non-nil assertion for the language server.

Parameters:

NameTypeDescription
keystringThe key of the new field
enumTypeEnumObjectThe enum type

Returns:

TypeDescription
self

AddDeferredNumberField

lua
function ReactiveStateSchema:AddDeferredNumberField(key, validateFunc)
  -> self

Defines a number field as part of the schema which can be nil (and is by default) but is defined with a non-nil assertion for the language server.

Parameters:

NameTypeDescription
keystringThe key of the new field
validateFuncfun(value: number): booleanA function used to validate values

Returns:

TypeDescription
self

AddDeferredStringField

lua
function ReactiveStateSchema:AddDeferredStringField(key, validateFunc)
  -> self

Defines a string field as part of the schema which can be nil (and is by default) but is defined with a non-nil assertion for the language server.

Parameters:

NameTypeDescription
keystringThe key of the new field
validateFuncfun(value: string): booleanA function used to validate values

Returns:

TypeDescription
self

AddDeferredTableField

lua
function ReactiveStateSchema:AddDeferredTableField(key, validateFunc)
  -> self

Defines a table field as part of the schema which can be nil (and is by default) but is defined with a non-nil assertion for the language server.

Parameters:

NameTypeDescription
keystringThe key of the new field
validateFuncfun(value: table): booleanA function used to validate values

Returns:

TypeDescription
self

AddEnumField

lua
function ReactiveStateSchema:AddEnumField(key, enumType, default)
  -> self

Defines an enum field as part of the schema.

Parameters:

NameTypeDescription
keystringThe key of the new field
enumTypeEnumObjectThe enum type
defaultEnumValueThe default value of the field

Returns:

TypeDescription
self

AddNumberField

lua
function ReactiveStateSchema:AddNumberField(key, default, validateFunc)
  -> self

Defines a number field as part of the schema.

Parameters:

NameTypeDescription
keystringThe key of the new field
defaultnumberThe default value of the field
validateFuncfun(value: number): booleanA function used to validate values

Returns:

TypeDescription
self

AddOptionalBooleanField

lua
function ReactiveStateSchema:AddOptionalBooleanField(key)
  -> self

Defines a boolean field as part of the schema which can be nil (and is by default).

Parameters:

NameTypeDescription
keystringThe key of the new field

Returns:

TypeDescription
self

AddOptionalClassField

lua
function ReactiveStateSchema:AddOptionalClassField(key, class)
  -> self

Defines an optional class field as part of the schema which can be nil (and is by default).

Parameters:

NameTypeDescription
keystringThe key of the new field
classT | TThe class or name of the class (subclasses are not permitted in the later case)

Returns:

TypeDescription
self

AddOptionalEnumField

lua
function ReactiveStateSchema:AddOptionalEnumField(key, enumType)
  -> self

Defines an enum field as part of the schema which can be nil (and is by default).

Parameters:

NameTypeDescription
keystringThe key of the new field
enumTypeEnumObjectThe enum type

Returns:

TypeDescription
self

AddOptionalNumberField

lua
function ReactiveStateSchema:AddOptionalNumberField(key, validateFunc)
  -> self

Defines a number field as part of the schema which can be nil (and is by default).

Parameters:

NameTypeDescription
keystringThe key of the new field
validateFuncfun(value: number): booleanA function used to validate values

Returns:

TypeDescription
self

AddOptionalStringField

lua
function ReactiveStateSchema:AddOptionalStringField(key, validateFunc)
  -> self

Defines a string field as part of the schema which can be nil (and is by default).

Parameters:

NameTypeDescription
keystringThe key of the new field
validateFuncfun(value: string): booleanA function used to validate values

Returns:

TypeDescription
self

AddOptionalTableField

lua
function ReactiveStateSchema:AddOptionalTableField(key, validateFunc)
  -> self

Defines a table field as part of the schema which can be nil (and is by default).

Parameters:

NameTypeDescription
keystringThe key of the new field
validateFuncfun(value: table): booleanA function used to validate values

Returns:

TypeDescription
self

AddStringField

lua
function ReactiveStateSchema:AddStringField(key, default, validateFunc)
  -> self

Defines a string field as part of the schema.

Parameters:

NameTypeDescription
keystringThe key of the new field
defaultstringThe default value of the field
validateFuncfun(value: string): booleanA function used to validate values

Returns:

TypeDescription
self

Commit

lua
function ReactiveStateSchema:Commit()
  -> self

Commits the schema and prevents further changes.

Returns:

TypeDescription
self

CreateState

lua
function ReactiveStateSchema:CreateState()

Creates a state object based on the schema.

Extend

lua
function ReactiveStateSchema:Extend(name)
  -> self

Returns a new state schema which extends the existing one

Parameters:

NameTypeDescription
namestringThe name of the extended schema

Returns:

TypeDescription
self

UpdateFieldDefault

lua
function ReactiveStateSchema:UpdateFieldDefault(key, default)
  -> self

Updates the default value of an existing field.

Parameters:

NameTypeDescription
keystringThe key of the field
defaultanyThe default value of the field

Returns:

TypeDescription
self

__tostring

lua
function ReactiveStateSchema:__tostring()

Functions

Create

lua
function ReactiveStateSchema.Create(name)
  -> ReactiveStateSchema

Creates a new state schema object.

Parameters:

NameTypeDescription
namestringThe name for debugging purposes

Returns:

TypeDescription
ReactiveStateSchema