OnInit

A mechanism for ReactiveViewModel initialization-time tasks like repository cache refresh.

With observe you get notified when the ViewModel is ready. On the provided OnInitContext you can launch coroutines which are associated with your observer. If any of the coroutines fail the state will reflect that and you can run trigger again for only the failing observers.

Types

Link copied to clipboard
sealed interface State

Properties

Link copied to clipboard
abstract val state: StateFlow<OnInit.State>

The initialization state.

Functions

Link copied to clipboard
abstract fun observe(block: OnInitContext.() -> Unit)
Link copied to clipboard
abstract fun trigger()
Link copied to clipboard
abstract fun unobserve(block: OnInitContext.() -> Unit)