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 constraintsDeclaration
Swift
static func constraints(requirements: FeatureConstraintsBuilder)
-
isEnabled
Default implementationBy 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 }
-
isAvailable
Extension methodCheck if a feature is available.
Note
It is safe to invoke this from any thread or queueDeclaration
Swift
static var isAvailable: Bool? { get }
-
descriptionOfUnsatisfiedConstraints
Extension methodGet a human readable description of what constraints are not currently satisfied and hence preventing the use of this feature.
Declaration
Swift
static var descriptionOfUnsatisfiedConstraints: String? { get }
-
permissions
Extension methodAccess information about the permissions required by this feature
Declaration
Swift
static var permissions: FeaturePermissionRequirements { get }
-
purchases
Extension methodAccess information about the purchases required by this feature
Declaration
Swift
static var purchases: FeaturePurchaseRequirements { get }
-
requiresUserToggle
Extension method- return:
true
if this feature is currently disabled at least in part because the user has not toggled it ON via the Flint user toggles API
Declaration
Swift
static var requiresUserToggle: Bool { get }
- return:
-
requiresRuntimeEnabled
Extension method- return:
true
if this feature is currently disabled at least in part because it requires runtime status ofisEnabled
to returntrue
and it is not currently.
Declaration
Swift
static var requiresRuntimeEnabled: Bool { get }
- return:
-
permissionAuthorisationController(using:)
Extension methodRequest permissions for all unauthorised permission requirements, using the supplied presenter
Declaration
Swift
static func permissionAuthorisationController(using coordinator: PermissionAuthorisationCoordinator?) -> AuthorisationController?