What are resources and why use them?

Resources are named entities accessible through data binding and value resolution. You can define them in resource blocks within APL documents and packages. Your skill can define resources conditionally based on viewport parameters.

In Lab 4, you used the ` alexa-layouts` package’s definitions of constants that represent the device types and viewport profiles in statements. The following code shows an example of the statements:

${@viewportProfile == @hubLandscapeLarge}

Entity @hubLandscapeLarge is a resource. So is @viewportProfile. (It’s a constant defined when the document displays.) Generally, you can reference resources with the following syntax:

@resourceName

By using Amazon pre-defined resources, you have already applied scaling to your APL documents without knowing all the possible screen-size permutations. Similarly, the benefit of creating your own resources is that you can define reusable entities. You can then use the entities throughout your APL document (like constants) without declaring the actual values more than one time. To ease maintenance and improve readability of your APL document, you can assign the resource values one time based on the profile or orientation of the screen your skill renders on, and then reference the resource names from that time onward.