SingletonHolder¶
Use SingletonHolder to build a singleton with parameters.
Get started¶
class Singleton private constructor(name: String) {
... // do other things.
companion object:SingletonHolder<Singleton,String>(::Singleton)
}
// Get the singleton.
private val singleton by lazy {
Singleton.getInstance(defaultLogTag())
}