I'm adding a listener to a task returned from a Firestore get()
request:
myQuery.get().addOnSuccessListener(Runnable::run)
{
/*does something*/
}
I know I can scope the listener to an activity with addOnSuccessListener(activity, ...)
which would remove the listener when the activity stops. But, to keep my code clean I need to remove the listener myself (when the rxJava observable that wraps the request is disposed of - using
emitter.setCancellable{
/*remove the listener here*/
}
).
How can I remove the listener from the task?