Kotlin Singleton Example with MVVM and Coroutines

High quality android courses: In this video I’m going to show you an example of how to use Singleton objects with Kotlin on Android. I’ll start by talking about: - Why we use singletons - When we use singletons Then I’ll show you two examples: **Example1:** In the first example I’ll build an example single class and print memory address to the log in MainActivity. This is very basic and is meant to introduce you to the concept of a singleton. **Example2:** The second example will be much more practical. I’m going to use MVVM architecture with a ViewModel, the Repository pattern, Kotlin coroutines and Retrofit. I will create a singleton Retrofit Builder and a singleton Repository. I’ll explain MVVM architecture and show you the latest and greatest best-practice method to return real data from a server using a GET request with Retrofit. Instagram: Twitter:
Back to Top