Appearance
ReactivePublisherSchema
The ReactivePublisherSchema class is used to define the data pipeline which handles observed values from ReactiveState or ReactiveStream objects. These data pipelines are compiled into Lua functions, so their execution is highly performant.
Stages
The data pipeline has two stages:
The first stage applies transformations and filters to published values. Transformations (e.g. :Map()) change the value passing to the next step. Filters (e.g. :Ignore*()) either allow the current value through or halt the pipeline. Any number of transformations and filters may be defined in any order.
The second stage handles the final value via :Call*() or :AssignToTableKey(). Exactly one of these must be called — it commits the schema and returns a ReactivePublisher object.
Share
The :Share() method designates that the value at that point in the pipeline should be saved and shared across multiple subsequent data pipelines. It returns a ReactivePublisherSchemaShared object, which allows continuing from the commit methods before being finalized via :EndShare().
lua
self._state:Publisher([[subAddEnabled and (mouseOver or hasFocus)]])
:Share()
:CallMethod(self._subIcon, "SetShown")
:CallMethod(self._subBtn, "SetShown")
:CallMethod(self._addIcon, "SetShown")
:CallMethod(self._addBtn, "SetShown")
:EndShare()Flat Map
The :FlatMapCall*() methods allow transforming published values into a new publisher, where the first argument is a function that receives published values and returns a new publisher.
Memory Management
Publisher schema objects are acquired exclusively via methods on ReactiveState and ReactiveStream and are recycled internally when committed.
API
Inherits: Class
Methods
AssignToTableKey
lua
function ReactivePublisherSchemaBase:AssignToTableKey(tbl, key)
-> selfAssigns published values to the specified key in the table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | table | The table to assign the published values into |
key | string | The key to assign the published values at |
Returns:
| Type | Description |
|---|---|
self |
CallFunction
lua
function ReactivePublisherSchemaBase:CallFunction(func, arg)
-> selfCalls a function with the published values.
Parameters:
| Name | Type | Description |
|---|---|---|
func | fun(value: T, arg: A) | The function to call with the published values |
arg | A | An additional argument to pass to the function |
Returns:
| Type | Description |
|---|---|
self |
CallMethod
lua
function ReactivePublisherSchemaBase:CallMethod(obj, method, arg)
-> selfCalls a method with the published values.
Parameters:
| Name | Type | Description |
|---|---|---|
obj | Obj | The object to call the method on |
method | K | The name of the method to call with the published values |
arg | any | An additional argument to pass to the method |
Returns:
| Type | Description |
|---|---|
self |
CoalesceNil
lua
function ReactivePublisherSchemaBase:CoalesceNil(value)
-> selfCoalesces nil published values to a specific value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | V | The value to map to |
Returns:
| Type | Description |
|---|---|
self |
FlatMapCallFunction
lua
function ReactivePublisherSchemaBase:FlatMapCallFunction(map, func, arg)
-> selfMaps published values to a new publisher which is owned by the current publisher and call a function with values it publishes.
Parameters:
| Name | Type | Description |
|---|---|---|
map | ReactivePublisherFlatMapFunc<T> | A function which takes a published value and returns a new publisher |
func | fun(value: T, arg: A) | The function to call with the published values |
arg | A | An additional argument to pass to the function |
Returns:
| Type | Description |
|---|---|
self |
FlatMapCallMethod
lua
function ReactivePublisherSchemaBase:FlatMapCallMethod(map, obj, method, arg)
-> selfMaps published values to a new publisher which is owned by the current publisher and call a method with values it publishes.
Parameters:
| Name | Type | Description |
|---|---|---|
map | ReactivePublisherFlatMapFunc<T> | A function which takes a published value and returns a new publisher |
obj | Obj | The object to call the method on |
method | K | The name of the method to call with the published values |
arg | any | An additional argument to pass to the method |
Returns:
| Type | Description |
|---|---|
self |
IgnoreDuplicates
lua
function ReactivePublisherSchemaBase:IgnoreDuplicates(hashFunc)
-> selfIgnores duplicate published values.
Parameters:
| Name | Type | Description |
|---|---|---|
hashFunc | string | A method call (in the form "MyMethod()") to calculate the hash to check for equality |
Returns:
| Type | Description |
|---|---|
self |
IgnoreDuplicatesWithKeys
lua
function ReactivePublisherSchemaBase:IgnoreDuplicatesWithKeys(...)
-> selfIgnores duplicate published values by checking the specified keys.
Parameters:
| Name | Type | Description |
|---|---|---|
... | K | Keys to compare to detect duplicate published values |
Returns:
| Type | Description |
|---|---|
self |
IgnoreIfEquals
lua
function ReactivePublisherSchemaBase:IgnoreIfEquals(value, key)
-> selfIgnores published values which equal the specified value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | V | The value to compare against |
key | K | The key to access for filtering |
Returns:
| Type | Description |
|---|---|
self |
IgnoreIfNotEquals
lua
function ReactivePublisherSchemaBase:IgnoreIfNotEquals(value, key)
-> selfIgnores published values which don't equal the specified value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | V | The value to compare against |
key | K | The key to access for filtering |
Returns:
| Type | Description |
|---|---|
self |
IgnoreNil
lua
function ReactivePublisherSchemaBase:IgnoreNil()
-> selfIgnores published values if it's nil.
Returns:
| Type | Description |
|---|---|
self |
InvertBoolean
lua
function ReactivePublisherSchemaBase:InvertBoolean()
-> selfInvert published boolean values.
Returns:
| Type | Description |
|---|---|
self |
IsShared
lua
function ReactivePublisherSchemaBase:IsShared()
-> booleanReturns whether or not this is a shared publisher.
Returns:
| Type | Description |
|---|---|
boolean |
Map
lua
function ReactivePublisherSchemaBase:Map(map, arg)
-> selfMap published values to another value.
Parameters:
| Name | Type | Description |
|---|---|---|
map | fun(value: T, arg: A): any | string | number | table<T, R> | Either a map function, table key (string or number) to index, method call (in the form "MyMethod()"), or lookup table |
arg | A | An additional argument to pass to a map function |
Returns:
| Type | Description |
|---|---|
self |
MapNonNil
lua
function ReactivePublisherSchemaBase:MapNonNil(map, arg)
-> selfMap non-nil publishes values to another value.
Parameters:
| Name | Type | Description |
|---|---|---|
map | fun(value: T, arg: A): R | string | table<T, R> | Either a map function, method call (in the form "MyMethod()"), or lookup table |
arg | A | An additional argument to pass to the map function or method |
Returns:
| Type | Description |
|---|---|
self |
Print
lua
function ReactivePublisherSchemaBase:Print(tag)
-> selfPrints published values and passes them through for debugging purposes.
Parameters:
| Name | Type | Description |
|---|---|---|
tag | string | An optional tag to add to the prints |
Returns:
| Type | Description |
|---|---|
self |
ReplaceBooleanWith
lua
function ReactivePublisherSchemaBase:ReplaceBooleanWith(trueValue, falseValue)
-> selfReplaces published boolean values with the specified true / false values.
Parameters:
| Name | Type | Description |
|---|---|---|
trueValue | V1 | The value to replace with to if true |
falseValue | V2 | The value to replace with to if false |
Returns:
| Type | Description |
|---|---|
self |
ReplaceWith
lua
function ReactivePublisherSchemaBase:ReplaceWith(value)
-> selfReplaces published values with the specific value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | V | The value to replace with |
Returns:
| Type | Description |
|---|---|
self |
ToBooleanEquals
lua
function ReactivePublisherSchemaBase:ToBooleanEquals(value)
-> selfMap published values to a boolean based on whether or not it equals the specified value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | T | The value to compare with |
Returns:
| Type | Description |
|---|---|
self |
ToBooleanGreaterThanOrEquals
lua
function ReactivePublisherSchemaBase:ToBooleanGreaterThanOrEquals(value)
-> selfMap published values to a boolean based on whether or not it is greater than or equal to the specified value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | T | The value to compare with |
Returns:
| Type | Description |
|---|---|
self |
ToBooleanLessThanOrEquals
lua
function ReactivePublisherSchemaBase:ToBooleanLessThanOrEquals(value)
-> selfMap published values to a boolean based on whether or not it is less than or equal to the specified value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | T | The value to compare with |
Returns:
| Type | Description |
|---|---|
self |
ToBooleanNotEquals
lua
function ReactivePublisherSchemaBase:ToBooleanNotEquals(value)
-> selfMap published values to a boolean based on whether or not it equals the specified value.
Parameters:
| Name | Type | Description |
|---|---|---|
value | T | The value to compare with |
Returns:
| Type | Description |
|---|---|
self |
ToStringFormat
lua
function ReactivePublisherSchemaBase:ToStringFormat(formatStr)
-> selfMap published values as arguments to a format string.
Parameters:
| Name | Type | Description |
|---|---|---|
formatStr | string | The string to format with the published values |
Returns:
| Type | Description |
|---|---|
self |
_AddStepHelper
lua
function ReactivePublisherSchemaBase:_AddStepHelper(stepType, ...)
-> selfParameters:
| Name | Type | Description |
|---|---|---|
stepType | EnumValue | |
... | any |
Returns:
| Type | Description |
|---|---|
self |
__init
lua
function ReactivePublisherSchemaBase:__init(isShared)Parameters:
| Name | Type | Description |
|---|---|---|
isShared | `` |
Inherits: ReactivePublisherSchemaBase, Class
Methods
AssignToTableKey
lua
function ReactivePublisherSchema:AssignToTableKey(tbl, key)
-> ReactivePublisherAssigns published values to the specified key in the table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | TBL | The table to assign the published values into |
key | K | The key to assign the published values at |
Returns:
| Type | Description |
|---|---|
ReactivePublisher |
CallFunction
lua
function ReactivePublisherSchema:CallFunction(func, arg)
-> ReactivePublisherCalls a function with the published values.
Parameters:
| Name | Type | Description |
|---|---|---|
func | fun(value: T) | The function to call with the published values |
arg | any | An additional argument to pass to the function |
Returns:
| Type | Description |
|---|---|
ReactivePublisher |
CallMethod
lua
function ReactivePublisherSchema:CallMethod(obj, method, arg)
-> ReactivePublisherCalls a method with the published values.
Parameters:
| Name | Type | Description |
|---|---|---|
obj | Obj | The object to call the method on |
method | K | The name of the method to call with the published values |
arg | any | An additional argument to pass to the method |
Returns:
| Type | Description |
|---|---|
ReactivePublisher |
FlatMapCallFunction
lua
function ReactivePublisherSchema:FlatMapCallFunction(map, func, arg)
-> ReactivePublisherMaps published values to a new publisher which is owned by the current publisher and call a function with values it publishes.
Parameters:
| Name | Type | Description |
|---|---|---|
map | ReactivePublisherFlatMapFunc<T> | A function which takes a published value and returns a new publisher |
func | fun(value: any) | The function to call with the published values |
arg | any | An additional argument to pass to the function |
Returns:
| Type | Description |
|---|---|
ReactivePublisher |
FlatMapCallMethod
lua
function ReactivePublisherSchema:FlatMapCallMethod(map, obj, method, arg)
-> ReactivePublisherMaps published values to a new publisher which is owned by the current publisher and call a method with values it publishes.
Parameters:
| Name | Type | Description |
|---|---|---|
map | ReactivePublisherFlatMapFunc<T> | A function which takes a published value and returns a new publisher |
obj | table | The object to call the method on |
method | string | The name of the method to call with the published values |
arg | any | An additional argument to pass to the method |
Returns:
| Type | Description |
|---|---|
ReactivePublisher |
Share
lua
function ReactivePublisherSchema:Share()
-> ReactivePublisherSchemaSharedShares the result of the publisher at the current point in the chain.
Returns:
| Type | Description |
|---|---|
ReactivePublisherSchemaShared |
_Acquire
lua
function ReactivePublisherSchema:_Acquire(subject)Parameters:
| Name | Type | Description |
|---|---|---|
subject | ReactiveSubject<T> |
_AddStepHelper
lua
function ReactivePublisherSchema:_AddStepHelper(stepType, ...)Parameters:
| Name | Type | Description |
|---|---|---|
stepType | `` | |
... | `` |
_Commit
lua
function ReactivePublisherSchema:_Commit()_Release
lua
function ReactivePublisherSchema:_Release()__init
lua
function ReactivePublisherSchema:__init()Functions
Get
lua
function ReactivePublisherSchema.Get(subject)
-> ReactivePublisherSchemaGets a publisher schema object.
Parameters:
| Name | Type | Description |
|---|---|---|
subject | ReactiveSubject<T> | The subject which is publishing values |
Returns:
| Type | Description |
|---|---|
ReactivePublisherSchema |
Inherits: ReactivePublisherSchemaBase, Class
Methods
AssignToTableKey
lua
function ReactivePublisherSchemaShared:AssignToTableKey(tbl, key)
-> selfAssigns published values to the specified key in the table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | table | The table to assign the published values into |
key | string | The key to assign the published values at |
Returns:
| Type | Description |
|---|---|
self |
CallFunction
lua
function ReactivePublisherSchemaShared:CallFunction(func, arg)
-> selfCalls a function with the published values.
Parameters:
| Name | Type | Description |
|---|---|---|
func | fun(value: TCur, arg: A) | The function to call with the published values |
arg | A | An additional argument to pass to the function |
Returns:
| Type | Description |
|---|---|
self |
CallMethod
lua
function ReactivePublisherSchemaShared:CallMethod(obj, method, arg)
-> selfCalls a method with the published values.
Parameters:
| Name | Type | Description |
|---|---|---|
obj | Obj | The object to call the method on |
method | K | The name of the method to call with the published values |
arg | any | An additional argument to pass to the method |
Returns:
| Type | Description |
|---|---|
self |
EndShare
lua
function ReactivePublisherSchemaShared:EndShare()
-> ReactivePublisherEnds the share.
Returns:
| Type | Description |
|---|---|
ReactivePublisher |
FlatMapCallFunction
lua
function ReactivePublisherSchemaShared:FlatMapCallFunction(map, func, arg)
-> selfMaps published values to a new publisher which is owned by the current publisher and call a function with values it publishes.
Parameters:
| Name | Type | Description |
|---|---|---|
map | ReactivePublisherFlatMapFunc<TCur> | A function which takes a published value and returns a new publisher |
func | fun(value: TCur, arg: A) | The function to call with the published values |
arg | A | An additional argument to pass to the function |
Returns:
| Type | Description |
|---|---|
self |
FlatMapCallMethod
lua
function ReactivePublisherSchemaShared:FlatMapCallMethod(map, obj, method, arg)
-> selfMaps published values to a new publisher which is owned by the current publisher and call a method with values it publishes.
Parameters:
| Name | Type | Description |
|---|---|---|
map | ReactivePublisherFlatMapFunc<TCur> | A function which takes a published value and returns a new publisher |
obj | Obj | The object to call the method on |
method | K | The name of the method to call with the published values |
arg | any | An additional argument to pass to the method |
Returns:
| Type | Description |
|---|---|
self |
_Acquire
lua
function ReactivePublisherSchemaShared:_Acquire(parentSchema, codeGen)Parameters:
| Name | Type | Description |
|---|---|---|
parentSchema | ReactivePublisherSchemaBase | |
codeGen | ReactivePublisherCodeGen |
_AddStepHelper
lua
function ReactivePublisherSchemaShared:_AddStepHelper(stepType, ...)Parameters:
| Name | Type | Description |
|---|---|---|
stepType | `` | |
... | `` |
_Commit
lua
function ReactivePublisherSchemaShared:_Commit()_Release
lua
function ReactivePublisherSchemaShared:_Release()__init
lua
function ReactivePublisherSchemaShared:__init()Functions
Get
lua
function ReactivePublisherSchemaShared.Get(parentSchema, codeGen)
-> ReactivePublisherSchemaSharedGets a shared publisher schema object.
Parameters:
| Name | Type | Description |
|---|---|---|
parentSchema | ReactivePublisherSchemaBase | The parent schema which is being shared |
codeGen | ReactivePublisherCodeGen | The code gen object to add steps to |
Returns:
| Type | Description |
|---|---|
ReactivePublisherSchemaShared |