wendy / com.levibostian.wendy.service / Wendy

Wendy

class Wendy

How you interact with Wendy with PendingTask instances you create. Add tasks to Wendy to run, get a list of all the PendingTasks registered to Wendy, etc.

Functions

addTask

fun addTask(pendingTask: PendingTask, resolveErrorIfTaskExists: Boolean = true): Long

Call when you have a new PendingTask that you would like to register to Wendy to run.

clear

fun clear(): Unit

Stop the task runner and clear all of the PendingTasks added to Wendy.

clearAsync

fun clearAsync(complete: () -> Unit?): Unit

Async version of clear.

debug

fun debug(enableDebug: Boolean = false): Wendy

Turn on and off debug log messages from Wendy.

doesErrorExist

fun doesErrorExist(taskId: Long): Boolean

Convenient method to see if an error has been recorded for a PendingTask and has not been resolved yet.

getAllErrors

fun getAllErrors(): List<PendingTaskError>

Get all errors that currently exist for PendingTasks.

getAllTasks

fun getAllTasks(): List<PendingTask>

If you, for some reason, wish to receive a copy of all the PendingTask instances that still need to run successfully by Wendy, here is how you get them.

getLatestError

fun getLatestError(taskId: Long): PendingTaskError?

How to check if an error has been recorded for a PendingTask.

isTaskAbleToManuallyRun

fun isTaskAbleToManuallyRun(taskId: Long): Boolean

Tells you if a PendingTask is able to run yet or not.

recordError

fun recordError(taskId: Long, humanReadableErrorMessage: String?, errorId: String?): Unit

If you encounter an error while executing PendingTask.runTask in one of your PendingTasks, you can record it here to handle later in your app. This is usually used when your PendingTask encounters an error that requires the app user to fix (example: A string sent up to your API is too long. The user must shorten it up).

resolveError

fun resolveError(taskId: Long): Boolean

Mark a previously recorded error for a PendingTask as resolved.

runTask

fun runTask(taskId: Long): Unit

Use this function along with manually run tasks to have Wendy run it for you. If it is successful, Wendy will take care of deleting it for you.

runTasks

fun runTasks(filter: RunAllTasksFilter?): Unit

Manually run all pending tasks. Wendy takes care of running this periodically for you, but you can manually run tasks here.

Companion Object Properties

shared

val shared: Wendy

Short hand version of calling sharedInstance.

Companion Object Functions

init

fun init(context: Context, tasksFactory: PendingTasksFactory): Wendy

Initialize Wendy. It's recommended to do this in your Application class of your app.

sharedInstance

fun sharedInstance(): Wendy

Get singleton instance of Wendy.