LazyForwardingEventListener.kt
TLDR
The LazyForwardingEventListener
class in the provided file forwards events to the EventListener
provided by a lazy evaluation.
Classes
LazyForwardingEventListener
This class forwards events to the EventListener
provided by a lazy evaluation. It implements the EventListener
interface and has a single method called onEvent
which is responsible for forwarding events to the lazy-evaluated EventListener
.
package leakcanary
import leakcanary.EventListener.Event
/**
* Forwards events to the [EventListener] provided by lazyEventListener which
* is evaluated lazily, when the first comes in.
*/
class LazyForwardingEventListener(
lazyEventListener: () -> EventListener
) : EventListener {
private val eventListenerDelegate by lazy(lazyEventListener)
override fun onEvent(event: Event) {
eventListenerDelegate.onEvent(event)
}
}