ConditionalActionBinding
public struct ConditionalActionBinding<FeatureType, ActionType> : CustomDebugStringConvertible where FeatureType : ConditionalFeature, ActionType : Action
A binding of feature and action for a conditional action that may not be available at runtime, depending on other factors e.g. feature flagging or IAPs.
You can call request()
on such a binding to see if its available in order to perform it:
public class TimelineFeature: ConditionalFeature {
public static var availability: FeatureAvailability = .runtimeEvaluated
public static var description: String = "Maintains an in-memory timeline of actions for debugging and reporting"
public static var isAvailable: Bool? = true
// ** This creates the conditional binding **
public static let loadData = action(LoadDataAction.self)
public static func prepare(actions: FeatureActionsBuilder) {
// Declare the action to Flint
actions.declare(loadData)
}
}
... elsewhere when you need to perform the action ...
if let request = TimelineFeature.loadData.request() {
// Perform it in the main session. Use `ActionSession.perform` to use other sessions.
request.perform(withInput: input, presenter: presenter)
} else {
fatalError("Should not have been able to chose this action, feature is disabled!")
}
Note
This is a completely discrete type fromStaticActionBinding
so that you cannot call perform
with a conditional action, you must first request the conditional action using this binding, and then
call perform with the VerifiedActionBinding
received from that.
-
Declaration
Swift
public var debugDescription: String { get }
-
Get a conditional action request if the feature of this binding is currently available. Otherwise, returns nil and the action cannot be performed.
See
ActionSession.perform
Declaration
Swift
public func request() -> VerifiedActionBinding<FeatureType, ActionType>?