onAsync

open fun <S : MavericksState, T> MavericksViewModel<S>.onAsync(asyncProp: KProperty1<S, Async<T>>, deliveryMode: DeliveryMode = RedeliverOnStart, onFail: suspend (Throwable) -> Unit? = null, onSuccess: suspend (T) -> Unit? = null): Job

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. This is useful for transient views that should only be shown once (toasts, poptarts), or logging. Most other views should use false, as when a view is destroyed and recreated the previous state is necessary to recreate the view.

Use uniqueOnly to automatically create a UniqueOnly mode with a unique id for this view.

Default: RedeliverOnStart.

onFail

supports cooperative cancellation. The previous action will be cancelled if it as not completed before the next one is emitted.

onSuccess

supports cooperative cancellation. The previous action will be cancelled if it as not completed before the next one is emitted.