Appearance
ReactiveState
Inherits: ReactiveSubject
Methods
GetDefaultValue
lua
function ReactiveState:GetDefaultValue(key)
-> anyGets the default value of a state field.
Parameters:
| Name | Type | Description |
|---|---|---|
key | string | The key to get the default value of |
Returns:
| Type | Description |
|---|---|
any |
Publisher
lua
function ReactiveState:Publisher(expressionStr)
-> ReactivePublisherSchemaCreates a publisher for an expression which operates on state fields.
Parameters:
| Name | Type | Description |
|---|---|---|
expressionStr | expression<self & ReactiveExprBuiltins, R> | A valid lua expression which can only access fields of the state (as globals) |
Returns:
| Type | Description |
|---|---|
ReactivePublisherSchema |
PublisherForFunctionWithKeys
lua
function ReactiveState:PublisherForFunctionWithKeys(func, ...)
-> ReactivePublisherSchemaCreates a new publisher which publishes the state when the result of a function which gets passed the specified keys changes. NOTE: The function must be constant and strictly depend on its inputs only.
Parameters:
| Name | Type | Description |
|---|---|---|
func | fun(...: any, ...): any | The function which gets the values of the specified keys and returns the value to publish (if it changes) |
... | string | The keys to pass to the function |
Returns:
| Type | Description |
|---|---|
ReactivePublisherSchema |
PublisherForKeys
lua
function ReactiveState:PublisherForKeys(...)
-> ReactivePublisherSchemaCreates a new publisher which publishes the state when any of the specified keys change.
Parameters:
| Name | Type | Description |
|---|---|---|
... | string | The keys to create a publisher for |
Returns:
| Type | Description |
|---|---|
ReactivePublisherSchema |
ResetToDefault
lua
function ReactiveState:ResetToDefault()Resets the state to its default value.
SetAutoDeferred
lua
function ReactiveState:SetAutoDeferred(deferred)Sets whether or not new publishers which are added should be deferred and handled as late as possible.
Parameters:
| Name | Type | Description |
|---|---|---|
deferred | boolean | Whether or not to defer publishers |
SetAutoDisable
lua
function ReactiveState:SetAutoDisable(disable)
-> selfSets whether or not new publishers are automatically disabled when stored.
Parameters:
| Name | Type | Description |
|---|---|---|
disable | boolean | Disable publishers when stored |
Returns:
| Type | Description |
|---|---|
self |
SetAutoStore
lua
function ReactiveState:SetAutoStore(tbl)
-> selfAutomatically stores any new publishers in the specified table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | table | The table to store new publishers in |
Returns:
| Type | Description |
|---|---|
self |
SetAutoStorePaused
lua
function ReactiveState:SetAutoStorePaused(paused)Sets whether automatic storing of new publisher is paused.
Parameters:
| Name | Type | Description |
|---|---|---|
paused | boolean | Pause or unpause automatic storing of publishers |
WithAutoStorePaused
lua
function ReactiveState:WithAutoStorePaused()
-> function, any, anyReturns an iterator which executes exactly once with auto store paused within the loop body.
Returns:
| Type | Description |
|---|---|
function | |
any | |
any |