-
- All Implemented Interfaces:
-
androidx.lifecycle.LifecycleOwner
public interface MavericksView implements LifecycleOwner
-
-
Method Summary
Modifier and Type Method Description abstract Unitinvalidate()Override this to handle any state changes from MavericksViewModels created through Mavericks Fragment delegates. UnitpostInvalidate()UniqueOnlyuniqueOnly(String customId)Return a UniqueOnly delivery mode with a unique id for this fragment. <S extends MavericksState> JobonEach(MavericksViewModel<S> $self, DeliveryMode deliveryMode, SuspendFunction1<S, Unit> action)Subscribes to all state updates for the given viewModel. <S extends MavericksState, A extends Any> <ERROR CLASS>onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, DeliveryMode deliveryMode, SuspendFunction1<A, Unit> action)Subscribes to state changes for only a specific property and calls the action with only that single property. <S extends MavericksState, A extends Any, B extends Any> <ERROR CLASS>onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, DeliveryMode deliveryMode, SuspendFunction2<A, B, Unit> action)Subscribes to state changes for two properties. <S extends MavericksState, A extends Any, B extends Any, C extends Any> <ERROR CLASS>onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, DeliveryMode deliveryMode, SuspendFunction3<A, B, C, Unit> action)Subscribes to state changes for three properties. <S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any> <ERROR CLASS>onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, DeliveryMode deliveryMode, SuspendFunction4<A, B, C, D, Unit> action)Subscribes to state changes for four properties. <S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any, E extends Any> <ERROR CLASS>onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, KProperty1<S, E> prop5, DeliveryMode deliveryMode, SuspendFunction5<A, B, C, D, E, Unit> action)Subscribes to state changes for five properties. <S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any> <ERROR CLASS>onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, KProperty1<S, E> prop5, KProperty1<S, F> prop6, DeliveryMode deliveryMode, SuspendFunction6<A, B, C, D, E, F, Unit> action)Subscribes to state changes for six properties. <S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any> <ERROR CLASS>onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, KProperty1<S, E> prop5, KProperty1<S, F> prop6, KProperty1<S, G> prop7, DeliveryMode deliveryMode, SuspendFunction7<A, B, C, D, E, F, G, Unit> action)Subscribes to state changes for seven properties. <S extends MavericksState, T extends Any> <ERROR CLASS>onAsync(MavericksViewModel<S> $self, KProperty1<S, Async<T>> asyncProp, DeliveryMode deliveryMode, SuspendFunction1<Throwable, Unit> onFail, SuspendFunction1<T, Unit> onSuccess)Subscribe to changes in an async property. <T extends Any> JobcollectLatest(Flow<T> $self, DeliveryMode deliveryMode, SuspendFunction1<T, Unit> action)Subscribes to the given Flow within the coroutine scope of the subscriptionLifecycleOwner, starting the flow only when the lifecycle is started, and executing with the coroutine context of Mavericks'subscriptionCoroutineContextOverride.StringgetMvrxViewId()MavericksViewInternalViewModelgetMavericksViewInternalViewModel()LifecycleOwnergetSubscriptionLifecycleOwner()-
-
Method Detail
-
invalidate
abstract Unit invalidate()
Override this to handle any state changes from MavericksViewModels created through Mavericks Fragment delegates.
-
postInvalidate
Unit postInvalidate()
-
uniqueOnly
UniqueOnly uniqueOnly(String customId)
Return a UniqueOnly delivery mode with a unique id for this fragment. In rare circumstances, if you make two identical subscriptions with the same (or all) properties in this fragment, provide a customId to avoid collisions.
- Parameters:
customId- An additional custom id to identify this subscription.
-
onEach
<S extends MavericksState> Job onEach(MavericksViewModel<S> $self, DeliveryMode deliveryMode, SuspendFunction1<S, Unit> action)
Subscribes to all state updates for the given viewModel.
- Parameters:
deliveryMode- If UniqueOnly when this MavericksView goes from a stopped to started lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onEach
<S extends MavericksState, A extends Any> <ERROR CLASS> onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, DeliveryMode deliveryMode, SuspendFunction1<A, Unit> action)
Subscribes to state changes for only a specific property and calls the action with only that single property.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onEach
<S extends MavericksState, A extends Any, B extends Any> <ERROR CLASS> onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, DeliveryMode deliveryMode, SuspendFunction2<A, B, Unit> action)
Subscribes to state changes for two properties.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onEach
<S extends MavericksState, A extends Any, B extends Any, C extends Any> <ERROR CLASS> onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, DeliveryMode deliveryMode, SuspendFunction3<A, B, C, Unit> action)
Subscribes to state changes for three properties.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onEach
<S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any> <ERROR CLASS> onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, DeliveryMode deliveryMode, SuspendFunction4<A, B, C, D, Unit> action)
Subscribes to state changes for four properties.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onEach
<S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any, E extends Any> <ERROR CLASS> onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, KProperty1<S, E> prop5, DeliveryMode deliveryMode, SuspendFunction5<A, B, C, D, E, Unit> action)
Subscribes to state changes for five properties.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onEach
<S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any> <ERROR CLASS> onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, KProperty1<S, E> prop5, KProperty1<S, F> prop6, DeliveryMode deliveryMode, SuspendFunction6<A, B, C, D, E, F, Unit> action)
Subscribes to state changes for six properties.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onEach
<S extends MavericksState, A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any> <ERROR CLASS> onEach(MavericksViewModel<S> $self, KProperty1<S, A> prop1, KProperty1<S, B> prop2, KProperty1<S, C> prop3, KProperty1<S, D> prop4, KProperty1<S, E> prop5, KProperty1<S, F> prop6, KProperty1<S, G> prop7, DeliveryMode deliveryMode, SuspendFunction7<A, B, C, D, E, F, G, Unit> action)
Subscribes to state changes for seven properties.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.action- supports cooperative cancellation.
-
onAsync
<S extends MavericksState, T extends Any> <ERROR CLASS> onAsync(MavericksViewModel<S> $self, KProperty1<S, Async<T>> asyncProp, DeliveryMode deliveryMode, SuspendFunction1<Throwable, Unit> onFail, SuspendFunction1<T, Unit> onSuccess)
Subscribe to changes in an async property. There are optional parameters for onSuccess and onFail which automatically unwrap the value or error.
- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to start lifecycle a state value will only be emitted if the state changed.onFail- supports cooperative cancellation.onSuccess- supports cooperative cancellation.
-
collectLatest
<T extends Any> Job collectLatest(Flow<T> $self, DeliveryMode deliveryMode, SuspendFunction1<T, Unit> action)
Subscribes to the given Flow within the coroutine scope of the
subscriptionLifecycleOwner, starting the flow only when the lifecycle is started, and executing with the coroutine context of Mavericks'subscriptionCoroutineContextOverride. This can be utilized to create customized subscriptions, for example, to drop the first element in the flow before continuing. This is intended to be used withviewmodel.stateflow.- Parameters:
deliveryMode- If UniqueOnly, when this MavericksView goes from a stopped to started lifecycle a value will only be emitted if the value has changed.action- supports cooperative cancellation.
-
getMvrxViewId
String getMvrxViewId()
-
getMavericksViewInternalViewModel
MavericksViewInternalViewModel getMavericksViewInternalViewModel()
-
getSubscriptionLifecycleOwner
LifecycleOwner getSubscriptionLifecycleOwner()
-
-
-
-