public protocol ConditionalFeature : ConditionalFeatureDefinition

Features that are not guaranteed to be available all the time must conform to this protocol.

You implement a conditional feature like so:

public class TimelineFeature: ConditionalFeature {
    /// Set the availability to .purchasRequired, .runtimeEvaluated or .userToggled as appropriate
    public static var availability: FeatureAvailability = .runtimeEvaluated

    public static var description: String = "Maintains an in-memory timeline of actions for debugging and reporting"

    /// If availability is `runtimeEvaluated`, you must make `isAvailable` return whether or not it is available.
    /// Otherwise do not define a property for it and the `DefaultAvailabilityChecker` will be used to work out
    /// the correct value of this by calling into the `UserDefaultsFeatureToggles` or `PurchaseValidator`.
    public static var isAvailable: Bool? = true

    /// If using `runtimeEvaluated` you can use this function to set `isAvailable` at startup based on
    /// some other condition. Beware of dependency on other features and non-determinate initialising sequence.
    public static func prepare(actions: FeatureActionsBuilder) {
        if isAvailable == true {
            // Tracks the user's history of actions performed
            Flint.dispatcher.add(observer: TimelineDispatchObserver.instance)

Apps must call request to test if the action is available, and then call perform with the resulting request instance.

  • request(_:) Default implementation

    Call to request invocation of the conditionally available action.

    • return: nil if the action’s feature is not available, or a request instance that can be used to perform the action directly or on a specific ActionSession if the feature is available

    Default Implementation

    Verifies that the feature is correctly prepared in Flint and tests isAvailable to see if it is true. If so, returns a request that can be used to perform the action, otherwise nil.

    The default isAvailable implementation will delegate to the AvailabilityChecker to see if the feature is available.



    static func request<T>(_ actionBinding: ConditionalActionBinding<Self, T>) -> ConditionalActionRequest<Self, T>? where T : Action