RSDTrackingTask
public protocol RSDTrackingTask
The tracking task protocol is intended for tasks that use scoring data from a previous task run to
inform subsequent runs of the same task by a given participant. RSDTaskViewModel
will check a task for
conformance to this method when the view model is initialized.
Note
Because sometimes it is actually the step navigator attached to a task that uses the previous
run data, the tracking task does not inherit from RSDTask
.
Seealso
RSDTaskObject
for example implementation.
-
Create and return the tracked data task that may be used to inform subsequent runs of this task.
Declaration
Swift
func taskData(for taskResult: RSDTaskResult) -> RSDTaskData?
Parameters
taskResult
The task result for this task that is used to build the task data.
Return Value
The task data or
nil
if there is no data to track. -
Called following initialization and before presentation of the task to allow setting up a task for custom navigation based on the previous stored data.
Declaration
Swift
func setupTask(with data: RSDTaskData?, for path: RSDTaskPathComponent)
Parameters
data
The stored task data.
path
The task path component that is calling this method. If a pointer is kept, it should use a weak reference.
-
Called before showing a step to conditionally skip the step in favor of instead adding the returned result to the step history. This can be used by tracking tasks to check a step for a previous result that is not expected to change across different runs, such as demographics data. Then if the app had a mechanism for storing the results of a previous run, it can skip this step on subsequent runs.
Declaration
Parameters
step
The step to check for previous run data.
Return Value
- shouldSkip: Whether or not the step should be skipped.
- stepResult: The step to add to the task result for this step in lieu of showing it.