mvrx-rxjava2 / com.airbnb.mvrx / MvRxView

MvRxView

interface MvRxView : MavericksView

Implement this in your MvRx capable Fragment.

When you get a ViewModel with fragmentViewModel, activityViewModel, or existingViewModel, it will automatically subscribe to all state changes in the ViewModel and call invalidate.

Functions

asyncSubscribe

open fun <S : MavericksState, T> BaseMvRxViewModel<S>.asyncSubscribe(asyncProp: KProperty1<S, Async<T>>, deliveryMode: DeliveryMode = RedeliverOnStart, 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.

selectSubscribe

open fun <S : MavericksState, A> BaseMvRxViewModel<S>.selectSubscribe(prop1: KProperty1<S, A>, deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (A) -> Unit): Disposable

Subscribes to state changes for only a specific property and calls the subscribe with only that single property.

open fun <S : MavericksState, A, B> BaseMvRxViewModel<S>.selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (A, B) -> Unit): Disposable

Subscribes to state changes for two properties.

open fun <S : MavericksState, A, B, C> BaseMvRxViewModel<S>.selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (A, B, C) -> Unit): Disposable

Subscribes to state changes for three properties.

open fun <S : MavericksState, A, B, C, D> BaseMvRxViewModel<S>.selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (A, B, C, D) -> Unit): Disposable

Subscribes to state changes for four properties.

open fun <S : MavericksState, A, B, C, D, E> BaseMvRxViewModel<S>.selectSubscribe(prop1: KProperty1<S, A>, prop2: KProperty1<S, B>, prop3: KProperty1<S, C>, prop4: KProperty1<S, D>, prop5: KProperty1<S, E>, deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (A, B, C, D, E) -> Unit): Disposable

Subscribes to state changes for five properties.

open fun <S : MavericksState, A, B, C, D, E, F> BaseMvRxViewModel<S>.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>, deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (A, B, C, D, E, F) -> Unit): Disposable

Subscribes to state changes for six properties.

open fun <S : MavericksState, A, B, C, D, E, F, G> BaseMvRxViewModel<S>.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>, deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (A, B, C, D, E, F, G) -> Unit): Disposable

Subscribes to state changes for seven properties.

subscribe

open fun <S : MavericksState> BaseMvRxViewModel<S>.subscribe(deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (S) -> Unit): Disposable

Subscribes to all state updates for the given viewModel.

Inheritors

BaseMvRxFragment

abstract class BaseMvRxFragment : Fragment, MvRxView

Make your base Fragment class extend this to get MvRx functionality.