Feature
public protocol Feature : FeatureDefinition
Classes conforming to Feature represent an always-available feature that can perform actions.
To define such a feature, conform to this protocol and declare static properties for the
actions it supports, using the action(Action.Type)
helper function. You then override prepare
and
use the actions builder to declare or publish those actions:
class DocumentManagementFeature: Feature, URLMapped {
static let description = "Create, Open and Save documents"
static let createNew = action(DocumentCreateAction.self)
static let openDocument = action(DocumentOpenAction.self)
static let closeDocument = action(DocumentCloseAction.self)
static let saveDocument = action(DocumentSaveAction.self)
static func prepare(actions: FeatureActionsBuilder) {
actions.declare(createNew)
actions.declare(openDocument)
actions.declare(closeDocument)
actions.declare(saveDocument)
}
static func urlMappings(routes: URLMappingsBuilder) {
routes.send("create", to: createNew)
routes.send("open", to: openDocument)
}
}
You can optionally override the default implementations of name
and description
of you want to change how the
feature is presented in logging and debug UI.
-note: This type exists simply to allow protocol extenions on this type that are not to be inherited by
ConditionalFeatureDefinition
, e.g. the differing action()
binding functions.
See
ConditionalFeature
for features that can be enabled or disabled based on some condition.
-
action(_:)
Extension methodFunction for binding a feature and action pair, to restrict how this can be done externally by app code.
Declaration
Swift
static func action<ActionType>(_ action: ActionType.Type) -> StaticActionBinding<Self, ActionType> where ActionType : Action
-
action(_:)
Extension methodUndocumented
Declaration
Swift
static func action<ActionType>(_ action: ActionType.Type) -> StaticActionBinding<Self, ActionType> where ActionType : IntentAction