Reputation: 1
I have defined singleton in Kotlin as object class where I have connection to Room database and most logic is written in this class. I have defined LiveData, but its value is null, since there must be observer to work.
How can I implement observer in object class? Is this possible since function observe() takes Lifecycle as paramer?
Upvotes: 0
Views: 691
Reputation: 5635
Use
MutableLiveData<String>().observeForever { }
method, which doesn't care about the lifecycle. Please post some code or better explain what you want to more relevant answer.
Upvotes: 1