Sensorberg Smart Spaces SDK for Android / com.sensorberg.response.livedata

Package com.sensorberg.response.livedata

Types

ResponseObserver

open class ResponseObserver<T, P>

Observer of a Response that splits the status into 3 methods.

RxObserver

class RxObserver<T, P>

LiveData that supplies a very RX style callbacks to receive observes.

Type Aliases

SimpleResponseObserver

typealias SimpleResponseObserver<T> = ResponseObserver<T, Void>

Functions

map

fun <I, O, P> <ERROR CLASS><Response<I, P>>.map(mapper: (I?) -> O?): <ERROR CLASS><Response<O, P>>

Maps the Response of this LiveData to a different type.

observe

fun <T, P> <ERROR CLASS><Response<T, P>>.observe(lifecycleOwner: <ERROR CLASS>): RxObserver<T, P>

Observes the Response attached to the life-cycle of the supplied lifecycleOwner.

observeResult

fun <T, P> <ERROR CLASS><Response<T, P>>.observeResult(cancellation: <ERROR CLASS><Boolean>? = null): RxObserver<T, P>

Observes the Response until SUCCESS or FAIL is received.

onExecuting

fun <T, P> <ERROR CLASS><Response<T, P>>.onExecuting(): <ERROR CLASS><Boolean>

Returns a LiveData indicating true/false when the Response.status is Response.Status.EXECUTING

onFail

fun <T, P> <ERROR CLASS><Response<T, P>>.onFail(): <ERROR CLASS><Exception>

Returns a LiveData that contains the Response.exception when the Response.status is Response.Status.FAIL

onProgress

fun <T, P> <ERROR CLASS><Response<T, P>>.onProgress(): <ERROR CLASS><P>

Returns a LiveData that contains the Response.progress when the Response.status is Response.Status.EXECUTING

onSuccess

fun <T, P> <ERROR CLASS><Response<T, P>>.onSuccess(): <ERROR CLASS><T>

Returns a LiveData that contains the Response.data when the Response.status is Response.Status.SUCCESS

timber

fun <T, P> <ERROR CLASS><Response<T, P>>.timber(string: String? = null): <ERROR CLASS><Response<T, P>>

Logs the values of this response using Timber.d. Returns this for easy call chaining