abstract class PendingTask : PendingTaskFields
Represents a single task to perform. Usually used to sync offline data stored on the device with online remote storage.
To use this class, create a subclass of it. It is not marked as abstract because these files are saved into a sqlite database and in order to do that, this file cannot be abstract.
PendingTask(manuallyRun: Boolean, dataId: String?, groupId: String?, tag: String)
Represents a single task to perform. Usually used to sync offline data stored on the device with online remote storage. |
open var createdAt: Long
The date/time that the task was created. |
|
open var dataId: String?
This field is used to help you identify what offline device data needs to be synced with online remote storage. Example: You have a sqlite database table named Employees. Your user creates a new Employee in your app. First, you will create a new Employee table row for this new employee and then create a new CreateEmployeePendingTask instance to sync this new Employees sqlite row with your online remote storage. Set dataId to the newly created Employee table row id. So then when your CreateEmployeePendingTask instance is run by Wendy, you can query your database and sync that data with your remote storage. |
|
open var groupId: String?
If this task needs to be run after a set of previous tasks before it were all successfully run then mark this property with an identifier for the group. Wendy will run through all the tasks of this group until one of them fails. When one fails, Wendy will then skip all the other tasks belonging to this group and move on. |
|
open var manuallyRun: Boolean
Sometimes you may want your user to be in charge of when a task is run. Setting manuallyRun to true will assert that this task does not get run automatically by the Wendy task runner. You will need to manually run the task yourself via Wendy.runTask. |
|
open var tag: String
This is annoying, I know. I hope to remove it soon. This identifies your subclass with Wendy so when Wendy queries your PendingTask in the sqlite DB, it knows to run your subclass. It's recommended to set the tag to: |
|
var taskId: Long?
ID of the PendingTask. After you have used Wendy.addTask to add this task to Wendy, this property will become populated and available to you. It is then up to you to hang onto this ID if you want to reference it later on. |
fun equals(other: Any?): Boolean
Run comparisons between two instances of PendingTask. |
|
fun hashCode(): Int
Your typical Java hashCode() function to match equals. |
|
open fun isReadyToRun(): Boolean
Override this to dynamically set if this task is ready to run or not. |
|
abstract fun runTask(): PendingTaskResult
The method Wendy calls when it's time for your task to run. This is where you will perform database operations on the device, perform API calls, etc. |
|
open fun toString(): String
Print contents of PendingTask. |
fun PendingTask.addTaskStatusListenerForTask(listener: PendingTaskStatusListener): Unit
Extension to WendyConfig.addTaskStatusListenerForTask easily from a PendingTask instance. |
|
fun PendingTask.doesErrorExist(): Boolean
Extension to Wendy.doesErrorExist easily from a PendingTask instance. |
|
fun PendingTask.getLatestError(): PendingTaskError?
Extension to Wendy.getLatestError easily from a PendingTask instance. |
|
fun PendingTask.hasBeenAddedToWendy(): Boolean
Checks to see if the PendingTask has been added to Wendy yet. |
|
fun PendingTask.isAbleToManuallyRun(): Boolean
Extension to Wendy.isTaskAbleToManuallyRun easily from a PendingTask instance. |
|
fun PendingTask.recordError(humanReadableErrorMessage: String?, errorId: String?): PendingTaskResult
Extension to Wendy.recordError easily from a PendingTask instance. |
|
fun PendingTask.resolveError(): Unit
Extension to Wendy.resolveError easily from a PendingTask instance. |