EventRouter
What a screen shows to its UI: the state to draw, the effects to perform and one way in for events.
A view model implements it by delegating to the router that the EventRouter function creates, so it extends no class of this library:
class TaskListViewModel(
scope: CoroutineScope = routerScope(),
handlers: Collection<EventHandler<*, TaskListUiState, TaskListEffect>>,
) : ViewModel(scope),
EventRouter<TaskListEvent, TaskListUiState, TaskListEffect> by EventRouter(
scope = scope,
initialState = TaskListUiState.Loading,
handlers = handlers,
)Content copied to clipboard
Functions
Link copied to clipboard
Sends event to the handler registered for its exact class, which runs it as its DispatchStrategy says. It returns at once and is safe to call from any thread.