RSDAsyncAction
public protocol RSDAsyncAction : AnyObject, NSObjectProtocol
A controller for an async action configuration.
-
Delegate callback for handling action completed or failed.
Declaration
Swift
var delegate: RSDAsyncActionDelegate? { get set }
-
The status of the controller.
Declaration
Swift
var status: RSDAsyncActionStatus { get }
-
Is the action currently paused?
Declaration
Swift
var isPaused: Bool { get }
-
The last error on the action controller.
Note
Under certain circumstances, getting an error will not result in a terminal failure of the controller. For example, if a controller is both processing motion and camera sensors and only the motion sensors failed but using them is a secondary action.Declaration
Swift
var error: Error? { get }
-
Results for this action controller.
Declaration
Swift
var result: RSDResult? { get }
-
The configuration used to set up the controller.
Declaration
Swift
var configuration: RSDAsyncActionConfiguration { get }
-
The associated task path to which the result should be attached.
Declaration
Swift
var taskViewModel: RSDPathComponent { get }
-
Available for watchOS.
This method should be called on the main thread with the completion handler also called on the main thread. This method is intended to allow the controller to request any permissions associated with this controller before the step change happens.
On an Apple watch, authorization handling is managed by using a handshake request that requires opening the paired phone and responding to the authorization on the phone. This is a cumbersome UX that must be handled using the app delegate so it is recommended that the architecture for apps that use the watch include authorization handling though the iPhone app prior to running a task on the watch.
Remark
The controller should call the completion handler with an
Error
if authorization failed. Whether or not the completion handler includes a non-nil result that includes the authorization status, is up to the developers and researchers using this controller as a tool for gathering information for their study. -
Available for macOS.
This method should be called on the main thread with the completion handler also called on the main thread. This method is intended to allow the controller to request any permissions associated with this controller before the step change happens.
It is the responsibility of the controller to manage the display of any alerts that are not controlled by the OS. The
viewController
parameter is the view controler that should be used to present any modal dialogs.Note
The calling view controller or application delegate should block any UI presentation changes until after the completion handler is called to ensure that any modals presented by the async controller or the OS aren’t swallowed by other UI events.
Remark
The controller should call the completion handler with an
Error
if authorization failed. Whether or not the completion handler includes a non-nil result that includes the authorization status, is up to the developers and researchers using this controller as a tool for gathering information for their study. -
Available for iOS and tvOS.
This method should be called on the main thread with the completion handler also called on the main thread. This method is intended to allow the controller to request any permissions associated with this controller before the step change happens.
It is the responsibility of the controller to manage the display of any alerts that are not controlled by the OS. The
viewController
parameter is the view controler that should be used to present any modal dialogs.Note
The calling view controller or application delegate should block any UI presentation changes until after the completion handler is called to ensure that any modals presented by the async controller or the OS aren’t swallowed by other UI events.
Remark
The controller should call the completion handler with an
Error
if authorization failed. Whether or not the completion handler includes a non-nil result that includes the authorization status, is up to the developers and researchers using this controller as a tool for gathering information for their study.Declaration
Swift
func requestPermissions(on viewController: UIViewController, _ completion: @escaping RSDAsyncActionCompletionHandler)
Parameters
viewController
The view controler that should be used to present any modal dialogs.
completion
The completion handler.
-
Start the asynchronous action with the given completion handler.
Note
The handler may be called on a background thread.Declaration
Swift
func start(_ completion: RSDAsyncActionCompletionHandler?)
Parameters
completion
The completion handler to call once the controller is started.
-
Pause the action. Ignored if not applicable.
Declaration
Swift
func pause()
-
Resume the action. Ignored if not applicable.
Declaration
Swift
func resume()
-
Stop the action with the given completion handler.
Note
The handler may be called on a background thread.Declaration
Swift
func stop(_ completion: RSDAsyncActionCompletionHandler?)
Parameters
completion
The completion handler to call once the controller has processed its results.
-
Cancel the action.
Declaration
Swift
func cancel()
-
Let the controller know that the task will move to the given step.
Declaration
Swift
func moveTo(step: RSDStep, taskViewModel: RSDPathComponent)
Parameters
step
The step that will be presented.
taskViewModel
The current state of the task.