on

inline fun <T : Event> Gateway.on(scope: CoroutineScope = this, crossinline consumer: suspend T.() -> Unit): Job(source)

Convenience method that will invoke the consumer on every event T created by Gateway.events.

The events are buffered in an unlimited buffer and launched in the supplied scope, which is Gateway by default. Each event will be launched inside the scope separately and any thrown Throwable will be caught and logged.

The returned Job is a reference to the created coroutine, call Job.cancel to cancel the processing of any further events for this consumer.