Bixby Developer Center

Guides

Lazy Properties

Definition and Implementation

Sometimes, properties can be too time-intensive or resource-expensive to be populated each time that a structure concept is called during a Search action. Lazy properties allow you to call these properties only when necessary by using the lazy-source key. For a given property that you don't want populated each time, you would associate the lazy property with a Fetch action, which is called asynchronously with that data on demand. Bixby would call this Fetch action, for example, in Details layouts or specific dialogs for structures.

property (%name%) {
type (%type%)
lazy-source (%lazy-action%)
}

Examples

You can find an example of using lazy properties in the lazy-source reference page. In that example, the Hotel structure has a HotelDetails properties that is only populated when users want more information on a hotel. It uses the GetHotelDetails action to get those HotelDetails.

The shoe sample capsule also uses lazy properties. The Shoe structure has an accessories lazy property:

  property (accessories) {
description (A list of accessories for a shoe.)
type (Accessory)
min (Optional) max(Many)
lazy-source (FindAccessories)
}

View eae9a8f on GitHub

A Shoe structure might have hundreds of available accessories available to it, which is more information than a user might need while browsing through a catalog. So setting accessories as lazy helps save both the user and the system time.

The FindAccessories action fetches the accessories data for each shoe, when called:

action (FindAccessories) {
type (Fetch)
collect {
input (shoe) {
type (Shoe)
min (Required)
prompt-behavior (AlwaysSelection)
}
}
output (Accessory)
}

View master on GitHub

When the data actually needs to be generated, such as in the Details view of Shoe, the property is called normally and the planner handles calling the FindAccessories action for that information.

macro-def (shoe-accessories) {
params {
param (shoe) {
type (Shoe)
min (Required) max (One)
}
}
content {
section {
title ("Accessories")
content {
partitioned {
content {
for-each (shoe.accessories) {
as (accessory) {
cell-area {
slot1 {
image {
shape (Circle)
url {
template ("/images/red-shoe-icon.png")
}
}
}
slot2 {
content {
order (PrimarySecondary)
primary {
template ("#{value(accessory.name)}")
}
secondary {
template ("#{value(accessory.details)}")
}
}
}
}
}
}
}
}
}
}
}
}

View master on GitHub