abstract class BaseMvRxViewModel<S : MvRxState> : MavericksViewModel<S>
Base ViewModel implementation that all other ViewModels should extend.
BaseMvRxViewModel(initialState: S)
Base ViewModel implementation that all other ViewModels should extend. |
fun <T> asyncSubscribe(asyncProp: KProperty1<S, Async<T>>, onFail: ((Throwable) -> Unit)? = null, onSuccess: ((T) -> Unit)? = null): Disposable
Subscribe to changes in an async property. There are optional parameters for onSuccess and onFail which automatically unwrap the value or error. fun <T, S : MvRxState> asyncSubscribe(viewModel: BaseMvRxViewModel<S>, asyncProp: KProperty1<S, Async<T>>, onFail: ((Throwable) -> Unit)? = null, onSuccess: ((T) -> Unit)? = null): Unit
Subscribe to changes in an async property in a different ViewModel. There are optional parameters for onSuccess and onFail which automatically unwrap the value or error. |
|
fun Disposable.disposeOnClear(): Disposable |
|
fun <T> Single<T>.execute(stateReducer: S.(Async<T>) -> S): Disposablefun <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. 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. |
|
fun logStateChanges(): Unit
Output all state changes to logcat. |
|
open fun onCleared(): Unit |
|
fun <A> selectSubscribe(prop1: KProperty1<S, A>, subscriber: (A) -> Unit): Disposable
Subscribe to state changes for only a single property. fun <A, S : MvRxState> selectSubscribe(viewModel: BaseMvRxViewModel<S>, prop1: KProperty1<S, A>, subscriber: (A) -> Unit): Unit
Subscribe to state changes for only a single property in a different ViewModel. fun <A, B> selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, subscriber: (A, B) -> Unit): Disposable
Subscribe to state changes for two properties. fun <A, B, S : MvRxState> selectSubscribe(viewModel: BaseMvRxViewModel<S>, prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, subscriber: (A, B) -> Unit): Unit
Subscribe to state changes for two properties in a different ViewModel. fun <A, B, C> selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, subscriber: (A, B, C) -> Unit): Disposable
Subscribe to state changes for three properties. fun <A, B, C, S : MvRxState> selectSubscribe(viewModel: BaseMvRxViewModel<S>, prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, subscriber: (A, B, C) -> Unit): Unit
Subscribe to state changes for three properties in a different ViewModel. fun <A, B, C, D> selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, subscriber: (A, B, C, D) -> Unit): Disposable
Subscribe to state changes for four properties. fun <A, B, C, D, S : MvRxState> selectSubscribe(viewModel: BaseMvRxViewModel<S>, prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, subscriber: (A, B, C, D) -> Unit): Unit
Subscribe to state changes for four properties in a different ViewModel. fun <A, B, C, D, E> selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, prop5: KProperty1<S, E>, subscriber: (A, B, C, D, E) -> Unit): Disposable
Subscribe to state changes for five properties. fun <A, B, C, D, E, S : MvRxState> selectSubscribe(viewModel: BaseMvRxViewModel<S>, prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, prop5: KProperty1<S, E>, subscriber: (A, B, C, D, E) -> Unit): Unit
Subscribe to state changes for five properties in a different ViewModel. fun <A, B, C, D, E, F> selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, prop5: KProperty1<S, E>, prop6: KProperty1<S, F>, subscriber: (A, B, C, D, E, F) -> Unit): Disposable
Subscribe to state changes for six properties. fun <A, B, C, D, E, F, S : MvRxState> selectSubscribe(viewModel: BaseMvRxViewModel<S>, prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, prop5: KProperty1<S, E>, prop6: KProperty1<S, F>, subscriber: (A, B, C, D, E, F) -> Unit): Unit
Subscribe to state changes for six properties in a different ViewModel. fun <A, B, C, D, E, F, G> selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, prop5: KProperty1<S, E>, prop6: KProperty1<S, F>, prop7: KProperty1<S, G>, subscriber: (A, B, C, D, E, F, G) -> Unit): Disposable
Subscribe to state changes for seven properties. fun <A, B, C, D, E, F, G, S : MvRxState> selectSubscribe(viewModel: BaseMvRxViewModel<S>, prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, prop5: KProperty1<S, E>, prop6: KProperty1<S, F>, prop7: KProperty1<S, G>, subscriber: (A, B, C, D, E, F, G) -> Unit): Unit
Subscribe to state changes for seven properties in a different ViewModel. |
|
fun subscribe(subscriber: (S) -> Unit): Disposable
For ViewModels that want to subscribe to itself. fun <S : MvRxState> subscribe(viewModel: BaseMvRxViewModel<S>, subscriber: (S) -> Unit): Unit
For ViewModels that want to subscribe to another ViewModel. |