Skip to content

Instantly share code, notes, and snippets.

@thoinv
Last active July 19, 2022 10:04
Show Gist options
  • Save thoinv/29a65d44b601c750b1923e3703ee02be to your computer and use it in GitHub Desktop.
Save thoinv/29a65d44b601c750b1923e3703ee02be to your computer and use it in GitHub Desktop.
[Singleton Kotlin] #kotlin
companion object {
private var INSTANCE: Repository? = null
val instance: Repository?
get() {
if (INSTANCE == null) {
synchronized(Repository::class.java) {
if (INSTANCE == null) {
INSTANCE =
Repository()
}
}
}
return INSTANCE
}
}
companion object {
val instance: BlockManager by lazy { BlockManager().init() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment