Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComponentModeControlManager

ControlManager used to render APL in Component Mode.

Hierarchy

Implements

Constructors

constructor

Properties

props

props: Readonly<Required<ControlManagerProps>>

The complete props used during construction.

Optional rawProps

The custom props provided during construction

Static DEFAULT_CONTROL_STATE_ATTRIBUTE_KEY

DEFAULT_CONTROL_STATE_ATTRIBUTE_KEY: string = "__controlState"

Default key name used to store control state data between turns.

Methods

buildInteractionModel

  • Builds interaction model content required by the Control tree.

    Usage:

    • The imDataMap has 'en-US' modelData registered by default

    • The developer may configure and register additional imDataMap instances to support additional locales

    • If imDataMap doesn't have data for the requested locale a LocaleNotSupportedError will be thrown

    Parameters

    Returns void

Abstract createControlTree

  • Creates a tree of controls to handle state management and dialog decisions for the skill.

    Usage:

    • Each control in the tree can and should be created with empty state.

    • In advanced scenarios the tree shape may change as the skill session progresses. Dynamic controls should be rebuilt during ControlManager.reestablishControlStates().

    Returns Control

    A Control, typically a ContainerControl, that is the root of a tree.

handleInternalError

  • Handles an internal error.

    This is intended for logging, reporting and perhaps mentioning the situation to the user. The user session will be automatically closed.

    Default: The error object is converted into an object with enumerable properties and logged at logLevel=error

    Parameters

    Returns void

loadControlStateMap

  • loadControlStateMap(handlerInput: HandlerInput): Promise<object>

reestablishControlStates

  • reestablishControlStates(rootControl: IControl, stateMap: object): void
  • Reestablish the state of all controls.

    Purpose:

    • On the second and subsequent turns this method reestablishes the state of controls from saved/serialized information.
    • This method should also reestablish any dynamic controls (controls that are added at runtime, rather than being statically created by createControlTree)

    Notes:

    • To keep serialized state to a minimum, and due to the lack of object-aware serialization in Javascript, re-creation of the complete control tree occurs in two phases:
      1. Build the static control tree as in the very first turn.
      2. Reattach state and rebuild the dynamic portions of the control tree.
    • This approach keeps the props and state of controls separate and keeps the common cases as simple as possible.

    Parameters

    • rootControl: IControl
    • stateMap: object
      • [key: string]: any

    Returns void

render

Abstract renderAPL

saveControlStateMap

  • saveControlStateMap(state: any, handlerInput: HandlerInput): Promise<void>
  • Saves the control state map for use in subsequent turns of this session.

    Default: saves to the Session Attributes.

    Parameters

    • state: any
    • handlerInput: HandlerInput

    Returns Promise<void>

Static loadControlStateMapFromSessionAttributes

  • loadControlStateMapFromSessionAttributes(handlerInput: HandlerInput, attributeKey: string): object

Static mergeWithDefaultProps

Static saveControlStateToSessionAttributes

  • saveControlStateToSessionAttributes(state: any, handlerInput: HandlerInput, attributeKey: string): void