Package-level declarations

Types

Link copied to clipboard
sealed interface Dispatch

What an EventRouter does with an event: the answer of a DispatchStrategy.

Link copied to clipboard
fun interface DispatchStrategy<in E : UiEvent>

Decides what an EventRouter does with an event while other events are running or waiting.

Link copied to clipboard
fun interface ErrorHandler<E : UiEvent, S : UiState, F : UiEffect>

Decides what a screen does when one of its event handlers fails.

Link copied to clipboard
interface EventHandler<E : UiEvent, S : UiState, F : UiEffect>

Handles one event type of one screen.

Link copied to clipboard
interface EventRouter<E : UiEvent, S : UiState, F : UiEffect>

What a screen shows to its UI: the state to draw, the effects to perform and one way in for events.

Link copied to clipboard
fun interface RouterObserver<in E : UiEvent>

Is told what an EventRouter does with each event: what the strategy of its handler answered, when its handler started, which effects it emitted, and how its run ended. Pass one to EventRouter(...) to log a screen, to see why an event did nothing, or to check in a test what the router did.

Link copied to clipboard
sealed interface RouterTrace<out E : UiEvent>

One thing an EventRouter did with an event, as its RouterObserver is told.

Link copied to clipboard

The state and the effects of one screen.

Link copied to clipboard
interface UiEffect

Something the UI must do once and then forget: show a message, navigate, vibrate.

Link copied to clipboard
interface UiEvent

Something that happened and must be handled: a tap, a text change, something to report to analytics.

Link copied to clipboard
interface UiState

The state of one screen: everything the UI needs to draw it, as one immutable value.

Functions

Link copied to clipboard
fun <E : UiEvent, S : UiState, F : UiEffect> EventRouter(scope: CoroutineScope, initialState: S, handlers: Collection<EventHandler<*, S, F>>, errorHandler: ErrorHandler<E, S, F>? = null, observer: RouterObserver<E>? = null): EventRouter<E, S, F>

Creates the router of one screen.

Link copied to clipboard
fun routerScope(): CoroutineScope

Creates a coroutine scope for a view model and its EventRouter.