main

square/leakcanary

Last updated at: 29/12/2023 09:39

DetectLeaksAssert.kt

TLDR

This file contains the DetectLeaksAssert interface, which defines the contract for the implementation that LeakAssertions.assertNoLeaks delegates to. It also includes a companion object with a default implementation and a static method to update the delegate.

Methods

N/A

Classes

N/A

package leakcanary

/**
 * The interface for the implementation that [LeakAssertions.assertNoLeaks] delegates to.
 * You can call [DetectLeaksAssert.update] to provide your own implementation.
 *
 * The default implementation is [AndroidDetectLeaksAssert].
 */
fun interface DetectLeaksAssert {

  fun assertNoLeaks(tag: String)

  companion object {
    @Volatile
    internal var delegate: DetectLeaksAssert = AndroidDetectLeaksAssert()

    fun update(delegate: DetectLeaksAssert) {
      DetectLeaksAssert.delegate = delegate
    }
  }
}