SingletonHolder
Use SingletonHolder to build a singleton with parameters.
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())
}
Content copied to clipboard
Since
0.0.3
Parameters
T
the singleton class.
A
the parameters class.