RequestHelper

class RequestHelper(main: CoroutineDispatcher, io: CoroutineDispatcher) : AbstractRequestHelper

A request helper that manages requests, retrying and blocking duplication

Since

v1.3.0

Parameters

main

Coroutine dispatchers for main thread operations

io

Coroutine dispatcher for IO operations

Constructors

Link copied to clipboard
constructor(main: CoroutineDispatcher, io: CoroutineDispatcher)

Functions

Link copied to clipboard
open override fun addListener(listener: IRequestHelper.Listener): Boolean

Adds a new listener that will be notified when any request load state changes: co.anitrend.arch.domain.entities.LoadState.

Link copied to clipboard

Creates a live data observable on the paging request helper

Link copied to clipboard
open suspend override fun hasAnyWithStatus(status: Request.Status): Boolean

Check if request handler has any finished request with status

Link copied to clipboard
open suspend override fun recordResult(wrapper: RequestWrapper, throwable: RequestError?)

Records the result of the result of a request

Link copied to clipboard
open override fun removeListener(listener: IRequestHelper.Listener): Boolean

Removes the given listener from the listeners list.

Link copied to clipboard
open suspend override fun retryWithStatus(status: Request.Status, action: suspend () -> Unit): Boolean

Retries all request types for a given status.

Link copied to clipboard
open suspend override fun runIfNotRunning(request: Request, handleCallback: suspend (RequestCallback) -> Unit): Boolean

Runs the given RequestCallback if no other requests in the given request type is already running. If run, the request will be run in the current thread.