DeferredProperty(title:)
A macro that creates an async property for an AppEntity that allows for providing an async get accessor.
Declaration
@attached(peer, names: prefixed(`$`), prefixed(`_`)) @attached(accessor, names: named(get), named(set)) macro DeferredProperty(title: LocalizedStringResource)Parameters
- title:
A localized string resource describing the property for display in the user interface.
Overview
Deferred properties have a few trade offs to consider:
They are not included when indexing and IndexedEntity
They are not sent to Shortcuts and Siri automatically and will only be fetched when needed
Example
struct Restaurant: AppEntity {
var model: Menu
@DeferredProperty
var popularItems: [MenuItem] {
get async {
await model.server.popularMenuItems()
}
}
}