Package com.tomtom.sdk.common.event

Types

Link copied to clipboard
class AdaptationThreadEventMessenger<T : Event>(looper: Looper, eventMessenger: SyncEventMessenger<T> = SyncEventMessenger()) : EventPublisher<T> , EventChannel<T> , Disposable

Messenger for generic events - allows publishing Events using provided Looper.

Link copied to clipboard
interface Event

An interface of a generic event.

Link copied to clipboard
interface EventChannel<out T : Event>

Generic event channel that allows registration of listeners that will be called when an event is published via an appropriate EventPublisher.

Link copied to clipboard
fun interface EventListener<in T : Event>

Generic event listener reporting an Event of the given type.

Link copied to clipboard
interface EventPublisher<in T : Event>

Generic event publisher. It should be used in conjunction with the EventChannel.

Link copied to clipboard
class LiveDataEvent<T> : MutableLiveData<T>

Extension of the MutableLiveData acting as single-shot observable event. Once a new data value is set, then the attached observer is notified only once. Note that only one observer is going to be notified of changes.

Link copied to clipboard
class SyncEventMessenger<T : Event> : EventPublisher<T> , EventChannel<T>

Synchronous messenger for generic events. It allows event publishing and also handles the subscription of event listeners.

Functions

Link copied to clipboard
suspend fun <T : Event> EventChannel<T>.awaitEvent(awaitedEvent: T): T

Waits till provided event appears in the EventChannel

Link copied to clipboard
fun <T : Event> EventChannel<T>.registerOneShotListener(filter: (T) -> Boolean = { true }, block: (T) -> Unit): Disposable

Registers EventListener that will be called only one time and only when given condition is met. Optional filter can be used to make the listener triggered only for certain events based on provided criteria. By default, all events are accepted. Once the listener is triggered, it will remove itself from this EventChannel automatically.