DataObserver

abstract class DataObserver<T> : DefaultLifecycleObserver

Public facing interface for users to grab data

Constructors

DataObserver
Link copied to clipboard
fun DataObserver()

Types

Thread
Link copied to clipboard
enum Thread : Enum<DataObserver.Thread>
Represents a thread in which the result of a subscribe should be handled on.

Functions

dispose
Link copied to clipboard
fun dispose()
isDisposed
Link copied to clipboard
fun isDisposed(): Boolean
onCreate
Link copied to clipboard
open fun onCreate(owner: LifecycleOwner)
onDestroy
Link copied to clipboard
open override fun onDestroy(owner: LifecycleOwner)
This will dispose any api calls being made from this observer
onPause
Link copied to clipboard
open override fun onPause(owner: LifecycleOwner)
onResume
Link copied to clipboard
open override fun onResume(owner: LifecycleOwner)
onStart
Link copied to clipboard
open fun onStart(owner: LifecycleOwner)
onStop
Link copied to clipboard
open fun onStop(owner: LifecycleOwner)
subscribe
Link copied to clipboard
fun subscribe(onSuccess: (T) -> Unit, onError: (Throwable) -> Unit = {}, thread: DataObserver.Thread = Thread.Main): DataObserver<T>
This will allow users to subscribe for data

Properties

onDisposed
Link copied to clipboard
var onDisposed: () -> Unit? = null
An optional callback that will be triggered after the DataObserver has been disposed.

Extensions

convertToRxJava
Link copied to clipboard
fun <T : Any> DataObserver<T>.convertToRxJava(): Single<T>
Converts a DataObserver back into an RxJava pipeline, as a Single.
getNow
Link copied to clipboard
fun <T> DataObserver<T>.getNow(): Pair<T?, Throwable?>
Provides blockingGet() functionality to DataObservers.