Reputation: 5876
Task
used in Firebase has method addOnSuccessListener(Activity, OnSuccessListener)
. The listener added using this method is automatically removed during activity's onStop()
.
What is the nearest equivalent for fragment? I.e. I want to add a listener inside a fragment but don't keep it after the fragment is closed.
Upvotes: 2
Views: 294
Reputation: 256
You can use LiveData & ViewModel:
Upvotes: 1