Jabbit Listener
Watches what happens to jobs, for logging, analytics and crash reporting.
Every method has an empty body, so an implementation overrides only what it cares about. Install one — or several — through jabbit { listener(...) }.
Callbacks arrive on whichever thread the job changed on, and a listener that throws is logged and skipped rather than allowed to break the scheduler. They are meant for quick, non-blocking work: anything slower belongs in a coroutine the listener launches itself.
jabbit {
worker(SyncJob) { SyncWorker(api) }
listener(object : JabbitListener {
override fun onFailed(job: JobInfo, error: Throwable?) {
crashReporter.report("job ${job.typeName} failed: ${job.failureReason}", error)
}
})
}On Android the scheduler is WorkManager, which also cancels work on its own — after WorkManager.cancelAllWork(), or when the application data is cleared. Those cancellations do not reach onCancelled, because they never pass through Jabbit.
Functions
The job will not run: it was cancelled, or replaced by another job of the same unique name.
The job was accepted into the queue.
The worker asked to run again.
The platform stopped the job mid-run — constraints stopped holding, a background window expired, or the process went away. It returns to JobState.ENQUEUED and runs again later.
The job finished successfully. A periodic job is already waiting for its next period.