EventNotifier
This is used to send events to an observer. All events are queued for later processing.
The possible events are defined as method calls on an interface T. This allows for easy composition of multiple events. One of the most common events interfaces is ErrorEvents.
See also
for more advanced usage of this pattern.
Example:
interface MyHandlerEvents : ErrorEvents, OtherEvents {
fun onSomethingHappened()
}
class MyHandler {
val eventNotifier = EventNotifier<MyHandlerEvents>()
fun doSomething() {
withErrorReporting(eventNotifier) {
if (computeResult() 5) {
eventNotifier { onSomethingHappened() }
} else {
eventNotifier { onOtherEvent() }
}
}
}
}
Functions
Maps a conflated Flow with timeoutMillis delay between the first and last element.
Transforms a conflated Flow with timeoutMillis delay between the first and last element.
Executes each lambda in a Flow using conflatedMap.
Executes each lambda in a Flow using debounce and map.
Consumes and handles EventNotifier's events on the given handler.
Executes each lambda in a Flow using debounce and mapLatest.
Turns this Flow into a SharedFlow without requiring a CoroutineScope (unlike shareIn).
Turns this Flow into a StateFlow without requiring a CoroutineScope (unlike stateIn).