UIManager
The UIManager class provides the framework for driving state updates in response to UI
interactions or other events. It also manages many of the other components of building a
state-driven UI, from creating the frame itself, to managing the state and related publishers.
Memory Management
The UIManager objects are intended to never be GC’d and have a static lifecycle (i.e. one
that’s equal to the lifecycle of the application), but there is nothing preventing them from being
GC’d.
API
-
class UIManager:
Class -
staticmethod Create(
name:string,
state:ReactiveState,
actionHandler: fun(manager:UIManager, state:ReactiveState, action:string, ...any)
):UIManager Creates a new UI manager object.
- Parameters:
name (
string) – The name for debugging purposesstate (
ReactiveState) – The stateactionHandler (fun(manager:
UIManager, state:ReactiveState, action:string, ...any)) – The action handler
-
SetStateFromPublisher(
self:UIManager,
key:string,
publisher:ReactivePublisherSchema
) Sets up a publisher to assign any published values to the state.
- Parameters:
key (
string) – The key to set in the statepublisher (
ReactivePublisherSchema) – The publisher
-
SetStateFromExpression(self:
UIManager, key:string, expression:string) Sets a state field based on the result of an expression on the state
- Parameters:
key (
string) – The key to set in the stateexpression (
string) – The expression to apply to the state
-
AddCancellable(self:
UIManager, publisher:ReactivePublisher) Adds a cancellable to be owned by the manager.
-
ProcessActionFromPublisher(
self:UIManager,
action:string,
publisher:ReactivePublisherSchema
) Processes an action whenever a value is published.
- Parameters:
action (
string) – The action to be processedpublisher (
ReactivePublisherSchema) – The publisher
-
MirrorStateWithTable(self:
UIManager, key:string, tbl:table, tblKey:string) Mirrors a state key with a given table.
- Parameters:
key (
string) – The state keytbl (
table) – The table to assign totblKey (
string) – The key within the table to assign to
-
CallbackToProcessAction(self:
UIManager, action:string): fun(...any) Returns a function which can be used as a callback to process the specified action.
- Parameters:
action (
string) – The action to be processed
-
ProcessAction(self:
UIManager, action:string, ...:any) Processes an action.
- Parameters:
action (
string) – The action... (
any) – Arguments for the action
-
ManageFuture(
self:UIManager,
stateKey:string,
future:Future,
action?:string
) Sends an action when a future is done (passing through the value).
- Parameters:
stateKey (
string) – The state key to store the future atfuture (
Future) – The futureaction? (
string) – The action to send
-
CancelFuture(self:
UIManager, stateKey:string) Cancels a future previously added via :ManageFuture().
- Parameters:
stateKey (
string) – The state key to use to store the future
-
SuppressActionLog(self:
UIManager, action:boolean|string):UIManager Suppresses logs for a given action
- Parameters:
action (
boolean|string) – The action or true to suppress all actions
-
AddFrameBuilder(
self:UIManager,
func: fun(state:ReactiveState, ...unknown):unknown
):UIManager Adds a UI frame building function.
- Parameters:
func (fun(state:
ReactiveState, ...unknown):unknown) – The function which builds the UI
-
BuildFrame(self:
UIManager, ...:unknown):unknown Builds a frame using a previously-registered builder.
- Parameters:
... (
unknown) – Additional arguments to pass to the frame builder
-
StatePublisherForKey(self:
UIManager, key:string):ReactivePublisherSchema Gets a publisher for a state key.
- Parameters:
key (
string) – The state key to get a publisher for.
-
staticmethod Create(