How to create and use a Singleton in Kotlin
A guide for creating and using Singletons in an Android app written in Kotlin.
How to create a Singleton
Create a new file named after the Singleton and implement code similar to that below.
We suggest placing it in a folder called Coordinators or Managers.
How to use a Singleton
To use a singleton variable, use a line similar to:
SampleCoordinator.shared.variableName
To run a function of a Singleton, use a line similar to:
SampleCoordinator.shared.function()
Any Questions?
We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.