LaxarJS widgets use flags to communicate boolean application state (true/false), usually to control parts of the user interface. For example, a flag might be used by an activity to indicate that some resource is currently in a dirty state, or that a popup layer is currently open. Consumers of flags respond to the state changes: a "save" button should be active while a resource is in the dirty state, and an animation on the main page should be paused while a popup is open.
As with resources and actions, flags are defined by the page configuration.
The didChangeFlag Event
Widgets that publish boolean state may do so by publishing a
To avoid race conditions, only one widget should be configured to publish state for a given flag on any single page.
Consumers of the
didChangeFlag event react simply by adapting to the modified state.
Usually, flag consumers take an arbitrary number of flag topics (configurable as an array in their features).
Consumers should consider the overall flag state to be true if any of their subscribed flags is true.
If no state as been received yet for a single flag, consumers should consider it to be false.
|Event name||Payload Attribute||Type||Description|
||published by any widget to communicate a boolean state|
||string||the topic through which flag consumer and producers are connected (used in the payload as well as in the event name)|
||boolean||the new state for the flag|
Because the flag
state is encoded in the event name as
"false", subscribers can use pattern matching to create two different subscriptions.