RouterObserver

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.

Every report prints as a sentence, so one line is a log:

observer = { println(it) }

// #1 OnSaveClick runs
// #1 OnSaveClick started
// #2 OnDeleteClick is ignored
// #1 OnSaveClick emitted Close
// #1 OnSaveClick completed

Reports arrive in order and one at a time, also when events are sent from several threads, but not always on the same thread. A report carries no time: a logger stamps its own lines.

Functions

Link copied to clipboard
abstract fun observe(trace: RouterTrace<E>)

Receives one report.