Reinflate Command


Reinflates the current document with updated configuration properties. Alexa rebuilds the entire document, following the same process as when initially displaying the document on the screen. Alexa creates a new, updated data-binding context with environment and viewport constants that match the new device configuration.

Properties

The Reinflate command has the properties shown in the following table, in addition to the common command properties. Set the type property to Reinflate.

In the following table, the "Default" column shows "Required" for properties that must have a value for the command to run. Otherwise it displays the default value, which might be none.

Property Type Default Description

preservedSequencers

Array of command sequencers

[]

An array of named sequencers to preserve during reinflation.

The document and component-level onMount commands run after the document reinflates.

The Reinflate command runs in both normal and fast mode.

For details about using reinflate to support tablets, see Support Tablets and Other Devices that Can Change Size.

preservedSequencers

The preservedSequencers property specifies an array of command sequencers to continue to run during and after reinflation. You can preserve the sequencers you define. You can't preserve the default MAIN sequencer.

For example, assume your document invokes the SpeakList command. As Alexa reads the list items, the user's device triggers a configuration change, which invokes Reinflate. The default behavior in this scenario stops all running commands when the document reinflates, which stops the SpeakList audio playback.

To continue the audio playback in this scenario instead, you do the following:

  • Define a sequencer for the SpeakList command.
      {
        "type": "Speaklist",
        "componentId": "myListToSpeak",
        "start": 0,
        "count": 10,
        "sequencer": "SpeakListSequencer"
      }
    
  • Set the preservedSequencers property for the Reinflate command to the sequencer you defined.
      {
        "type": "Reinflate",
        "preservedSequencers": [ "SpeakListSequencer" ]
      }
    

For details about how an individual command handles reinflation, see the reinflation strategy section for the specific command.

Extension commands don't support preservation.

Target components that exist

Make sure that commands on preserved sequencers target components that exist in the reinflated hierarchy. Provide an id for the component, and use the preserve property to save the values of component properties and bindings.

When a preserved sequencer runs a command that doesn't resolve instantly, such as AnimateItem or Scroll, the command continues after reinflation if the target component exists in the reinflated hierarchy.

Any commands running on the preserved sequencer that target non-existent components are ignored during reinflation.

For example, assume the following command is running on the "EXAMPLE_SEQUENCER" sequencer (t = 0):

{
  "type": "Sequential",
  "sequencer": "EXAMPLE_SEQUENCER",
  "commands": [
    {
      "type": "AnimateItem",
      "componentId": "MyComponent"
      "duration": 1000,
      "easing": "linear"
      "value": {
        "property": "opacity",
        "from": 0,
        "to": 1
        }
    },
    {
      "type": "SpeakItem",
      "componentId": "MyMissingComponent"
    },
    {
      "type": "SendEvent",
      "arguments": [ "finished" ]
    }
  ]
}

At t = 300 ms, a Reinflate command preserving the "EXAMPLE_SEQUENCER" sequencer runs. After reinflation, the reinflated hierarchy has a component with id MyComponent, but doesn't have a component with id MyMissingComponent. Because the reinflation happened before the AnimateItem finished, the component MyComponent has opacity set to 0.3. The AnimateItem command continues from where it left off and runs for 700 ms.

At t = 1 s, the SpeakItem command fails to find the component with id MyMissingComponent and returns. Then, the SendEvent command runs.

Commands specified in the document onMount handler or the component onMount handler run after reinflation. These commands terminate any preserved sequencers of the same name.

For more about reinflation, see Support Tablets and Other Devices that Can Change Size.

Combine Reinflate with other commands

Running Reinflate command stops all other processing in APL, including any commands that are running on sequencers not named in the preservedSequencers array. For details about sequencers and command sequencing, see Command sequencing.

For example, to run both SendEvent and Reinflate in the same handler, invoke SendEvent first. The following example sends a UserEvent request to the skill, and then reinflates the document.

{
  "onConfigChange": [
    {
      "type": "SendEvent",
      "sequencer": "ConfigSendEvent",
      "arguments": [
        "reinflating the APL document"
      ]
    },
    {
      "type": "Reinflate"
    }
  ]
}

If you write the commands the reverse order, the SendEvent never runs. The SendEvent command in this example defines a sequencer because the onConfigChange handler runs in fast mode. Fast mode ignores SendEvent.


Was this page helpful?

Last updated: frontmatter-missing