If I have a call, that is potentially leaking (no ...
# rx
u
If I have a call, that is potentially leaking (no way of removing the listener)
g
But you can remove listener, you can stop this task and listener will be removed
u
how?? I cannot pass null, nor there is remoteXyz method
g
Hah! Your right, you cannot cancel it, only if pass activity and it will be cancelled on lifecycle, sorry for confusion
what a garbage API
the only way to avoid leak is use weak reference than
or in case of activity pass activity as argument to addOnSuccessListener
u
hm, Im not sure how weakref can work if the api requires concrete listener class? maybe pass hard reference but keep that as a weakref in the enclosing class?
Copy code
val ref = WeakReference( new listener )
FirebaseWhatevef.addOnSuccessListener(ref.get())
g
no, I mean weakreference on objects inside of this listener, for example Emitter that used to deliver values to Rx