Defining Actions
-
A type that describes a particular action that the user can perform and how to perform it.
There are several subprotocols of
UserAction
that each provide a different way for types to define how they perform a user action:SimpleUserAction
: a simple action that performs a task synchronously.SyncUserAction
: a synchronous action that uses the action context.ReactiveUserAction
: a possibly asynchronous action that reports its result with a publisher.
To implement a user action, a type should conform to exactly one of the above protocols and implement the appropriate method to define how to do its work.
See moreDeclaration
Swift
public protocol UserAction
-
A synchronous user action that doesn’t need anything from the action context.
This is the simplest way to define a user action.
See moreDeclaration
Swift
public protocol SimpleUserAction : SyncUserAction
-
A user action that performs its work synchronously.
See moreDeclaration
Swift
public protocol SyncUserAction : ReactiveUserAction
-
A type of
UserAction
that signals its success or failure through a publisher.This is usually used for actions that do their work asynchronously. For synchronous work, it’s easier to implement
See moreSyncUserAction
orSimpleUserAction
.Declaration
Swift
public protocol ReactiveUserAction : UserAction
-
A type of
UserAction
that performs destructive work which may be worth confirming with the user.Conformance to this protocol should be added in addition to one of the other
See moreUserAction
protocols.Declaration
Swift
public protocol DestructiveUserAction : UserAction