1 package leakcanary
2 
3 /**
4  * Listener used by [ObjectWatcher] to report retained objects.
5  *
6  * This is a functional interface with which you can create a [OnObjectRetainedListener] from a lambda.
7  */
interfacenull8 fun interface OnObjectRetainedListener {
9 
10   /**
11    * A watched object became retained.
12    */
13   fun onObjectRetained()
14 
15   companion object {
16     /**
17      * Utility function to create a [OnObjectRetainedListener] from the passed in [block] lambda
18      * instead of using the anonymous `object : OnObjectRetainedListener` syntax.
19      *
20      * Usage:
21      *
22      * ```kotlin
23      * val listener = OnObjectRetainedListener {
24      *
25      * }
26      * ```
27      */
28     inline operator fun invoke(crossinline block: () -> Unit): OnObjectRetainedListener =
29       OnObjectRetainedListener { block() }
30   }
31 }
32