of

inline fun <T : Event> EventListener.Companion.of(crossinline handler: (T) -> Unit): EventListener<T>

Creates a new event listener that listens for events of the given event type T, running the given handler when an event of the correct type is fired.

Return

a new event listener

Parameters

T

the type of events the listener will listen for

handler

the handler for the listener