fun <T> Single<T>.execute(stateReducer: S.(Async<T>) -> S): Disposable
Helper to map a Single to an Async property on the state object.
fun <T, V> Single<T>.execute(mapper: (T) -> V, stateReducer: S.(Async<V>) -> S): Disposable
Helper to map a Single to an Async property on the state object.
mapper - A map converting the Single type to the desired Async type.
stateReducer - A reducer that is applied to the current state and should return the
new state. Because the state is the receiver and it likely a data
class, an implementation may look like: { copy(response = it) }.
fun <T> Observable<T>.execute(stateReducer: S.(Async<T>) -> S): Disposable
Helper to map an Observable to an Async property on the state object.
fun Completable.execute(stateReducer: S.(Async<Unit>) -> S): Disposable
Helper to map a Completable to an Async property on the state object.
fun <T, V> Observable<T>.execute(mapper: (T) -> V, successMetaData: ((T) -> Any)? = null, stateReducer: S.(Async<V>) -> S): Disposable
Execute an Observable and wrap its progression with Async property reduced to the global state.
mapper - A map converting the Observable type to the desired Async type.
successMetaData - A map that provides metadata to set on the Success result.
It allows data about the original Observable to be kept and accessed later. For example,
your mapper could map a network request to just the data your UI needs, but your base layers could
keep metadata about the request, like timing, for logging.
stateReducer - A reducer that is applied to the current state and should return the
new state. Because the state is the receiver and it likely a data
class, an implementation may look like: { copy(response = it) }.
See Also