registerOneShotListener

fun <T : Event> EventChannel<T>.registerOneShotListener(filter: (T) -> Boolean = { true }, block: (T) -> Unit): AutoCloseable

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.

Important: This is a Public Preview API. It may be changed or removed at any time.

Return

AutoCloseable that can be used to remove one-shot listener if it is still registered (not yet triggered). Calling this AutoCloseable after listener was fired will have no effect.