https://kotlinlang.org logo
#rx
Title
j

jw

05/25/2018, 1:43 PM
you should not be implementing a disposable with a lambda
u

ubu

05/25/2018, 8:50 PM
@jw, you mean, I should create an Disposable, like this:
Copy code
emitter.setDisposable(Disposables.fromAction {
             orderReference.child(id).removeEventListener(listener)
            })
j

jw

05/25/2018, 8:51 PM
yep. but if you're doing that you should probably just use the
setCancellable
which will handle creating that wrapper for you and allow you to use the superior lambda
u

ubu

05/25/2018, 9:17 PM
@jw, thanks, really. than I just don’t get what’s the difference between setCancellable() and setDisposable() if we only want to get a callback when this stream is unsubscribed.
j

jw

05/25/2018, 9:18 PM
cancellable is the callback, disposable is a disposable which is a more involved type that has a lifecycle and idempotency associated
💥 1
3 Views