Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Priority queue job example
class SendDataJob(private val dataInput: SomeDataClass) :
Job(Params(1).requireNetwork().persist().groupBy(“tag”)), KoinComponent {
// job is queued, need to update local storage
override fun onAdded() {
override fun onRun() {
val sendService: SendService? by inject()
?.observeOn(, true)
?.subscribe({}, {})
override fun onCancel(cancelReason: Int, throwable: Throwable?) {
override fun shouldReRunOnThrowable(throwable: Throwable, runCount: Int, maxRunCount: Int): RetryConstraint? {
if (throwable is HttpException) {
//if it is a 4xx error, stop
val errorCode = throwable.code()
return if (errorCode < 400 || errorCode > 499)
RetryConstraint.RETRY else RetryConstraint.CANCEL
return RetryConstraint.RETRY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.