SingletonHolder

open class SingletonHolder<R : Any, in T>(creator: (T) -> R) : InstanceHolder<R>

Create lazy singleton.

Example:

class PrefsHelper private constructor(context: Context) {
...
companion object : SingletonHolder<PrefsHelper, Context>(::PrefsHelper)
}

Since

1.4.0

Constructors

Link copied to clipboard
constructor(creator: (T) -> R)

Properties

Link copied to clipboard
@Volatile
var _instance: R?

Functions

Link copied to clipboard
protected inline fun getInstance(creator: () -> R): R
Link copied to clipboard
operator fun invoke(arg: T): R