Determines if the Control or one of its children can consume a request.
Returning true
does not guarantee that the Control will be selected.
Usage:
The handling of a request can and should be contextual. That is, a
control should only return canHandle = true
if the request makes
sense for the current state of the control.
A @see ContainerControl should return true if one or more of its
children returns canHandle = true
. Thus the root of a Control tree
should return canHandle = true
unless the request cannot be
meaningfully consumed by any Control in the tree.
The implementation should be deterministic and effectively memoryless.
i.e. no state changes should be made that would be exposed by
getSerializableState()
.
Input object. input.request
contains the request to be
handled.
true
if the Control or one of its children can consume the
entire request, false
otherwise.
Determines if the Control can take the initiative.
Usage:
A control should only return canTakeInitiative = true
if the control, in its
current state, has something important to ask of the user. This could be a
necessary elicitation, clarification, confirmation or some other activity to
obtain and finalize the information managed by the Control.
A @see ContainerControl should return true
if one of its children returns
canTakeInitiative = true
or if the container needs to ask the user a question
directly. Thus the root of a Control tree should return canTakeInitiative = true
if any control in the entire tree reports canTakeInitiative = true
.
The implementation should be deterministic, idempotent, and effectively memoryless. Effectively memoryless means that any state changes are temporary and will not be exposed in the serialized state.
Framework behavior:
.takesInitiative = true
.Input object.
true
if the Control or one of its children can take the initiative,
false
otherwise.
Evaluate an APL document/data source prop.
act
The input object
Constant or function producing a map of key:value pairs
Evaluate a boolean prop.
Constant or function producing boolean
The input object
Evaluate a prompt prop.
act
Constant or function producing String or List-of-Strings
Input object
Gets the Control's state as an object that is serializable.
Only durable state should be included and the object should be
serializable with a straightforward application of
JSON.stringify(object)
.
Default: {return this.state;}
Usage:
.state
variable
and only store simple data.Framework behavior:
JSON.stringify
.control.setSerializableState(serializedState)
.Serializable object defining the state of the Control
Handles the request.
Handling a request involves orchestrating state changes to the Control
(and its children) and adding response items to the
ControlResultBuilder
.
input.request
contains the request to be handled.
Collect SystemActs
that represent the system
output.
Determines if the Control's value is ready for use by other parts of the skill.
Note:
isReady === !canTakeInitiative
because isReady
implies
that no further discussion is required and thus there is no need to take the
initiative.Input object.
true
if the control has no further questions to ask the user such as
elicitation, clarification or confirmation.
Reestablishes the state of the control.
Default implementations:
Control
: reestablishes the state via
this.setSerializableState(state)
.ContainerControl
: reestablishes the state
and recursively
reestablishes state for all children.DynamicContainerControl
: reestablishes the state
, rebuilds any
dynamic child controls, and recursively reestablishes state for all
children.Add response APL component by this control.
This is intended to be used to provide APL rendering component for a control to process inputs, provide feedback, elicitation etc through touch events on APL screens.
Input
Response builder
Add response content for a system act produced by this control.
This is intended to be used with the default ControlManager.render() which implements a simple concatenation strategy to form a complete response from multiple result items.
System act
Input
Response builder
Sets the state from a serialized state object.
Default: {this.state = serializedState;}
Usage:
Framework behavior:
Serializable object defining the state of the Control
Takes initiative by adding an InitiativeAct to the result.
Framework behavior:
.takesInitiative = true
.Input object.
ResultBuilder. Collect SystemActs
that represent
the system output.
Abstract base class for Controls.
Purpose:
Usage:
ContainerControl
instead.