Contents

ControlValueProvider

A type that provides a value to a control template.

Declaration

protocol ControlValueProvider

Overview

The provider quickly and cheaply prepares a synchronous value to be shown while previewing the control in the add sheet. When the actual control needs to be rendered, the actual, current value will be fetched asynchronously.

For instance, a control that opens and closes a garage door may show a preview of the door being closed. When the actual control is rendered, the control may fetch the door’s status from the cloud:

struct GarageDoorValueProvider: ControlValueProvider {
    var previewValue: Bool { false }

    func currentValue() async -> Bool {
        await GarageDoorManager.shared.doorStatus()
    }
}

Topics

Associated Types

Instance Properties

Instance Methods

See Also

Previews