ConditionalFeatureDefinition

public protocol ConditionalFeatureDefinition : FeatureDefinition

A feature that is not guaranteed to always be available must conform to ConditionalFeatureDefinition, so that we can ensure the caller always verifies their availability before performing them.

This type exists separately from ConditionalFeature so that other types of conditional feature can exist (e.g. a future ConditionalFeatureGroup).

We also have this type to enable us to reference conditional features without generic constraint issues that arise from the Self requirement of ConditionalFeature. This allows us to define helper functions that operate on conditional features without having to deal with those problems.

Note

Accesses to any properties that may change at runtime, e.g. isAvailable must only occur on the main thread.
  • Called to define the requirements of this feature

    See

    FeatureConstraintsBuilder for the functions you can call to define constraints

    Declaration

    Swift

    static func constraints(requirements: FeatureConstraintsBuilder)
  • isEnabled Default implementation

    By default features with a runtime precondition are neither enabled nor disabled. Override this in your own types to set it to a default at runtime, or enable changing it at runtime

    Default Implementation

    By default features with a runtime precondition are neither enabled nor disabled. Override this in your own types to set it to a default at runtime, or enable changing it at runtime

    Declaration

    Swift

    static var isEnabled: Bool? { get }