Specify a Fetch
action that loads data for the property asynchronously. Sometimes it is too resource-expensive or time-intensive to populate a property of a structure in a Search
action. In these cases, you can give the property a lazy-source
action, which performs an asynchronous fetch of the property's data on demand. Bixby calls the lazy source when the property is referenced either in a layout or dialog. Once Bixby calls the lazy action, the property data is cached with the rest of the structure, resulting in only one lazy fetch call.
In this example from the Simple Search walkthrough, additional details about a shoe's possible accessories are fetched using lazy-source
.
structure (Shoe) {
property (name) {
type (Name)
min (Required)
}
property (description) {
type (Description)
min (Required)
}
property (type) {
type (Type)
min (Required)
}
property (price) {
type (money.Price)
min (Required)
}
property (accessories) {
description (A list of accessories for a shoe.)
type (Accessory)
min (Optional) max(Many)
lazy-source (FindAccessories)
}
property (images) {
type (Image)
max (Many) min (Required)
}
}
Once the FindAccessories
action is called and returns one or more Accessory
concepts, those concepts will be assigned to the accessories
property of the Shoe
and cached for subsequent use.
For more information about lazy-source
, read the Developers' Guide on Lazy Properties.