Is there a clean way to send a fire and forget req...
# rx
g
Is there a clean way to send a fire and forget request through rx? There's nothing to be done upon returning, so an empty
.subscribe()
would make sense, but if the request fails for some reason the app crashes because there is no
onError
handling. However, if I give it something so that it feels it has error handlung, like
.subscribe({ }, { })
, I'll be passing on indirect reference to the enclosing class, which would prevent it from being garbage collected until the request returned. Is there some sort of standard way of acting on such scenario?
z
If you want to suppress exceptions, you could use
onErrorResume(empty())
before your subscribe
j
An empty lambda will not capture, but you can also use
Actions.empty()
or whatever it's called
g
So by passing down
empty()
either to
subscribe()
or
onErrorResume()
I'll solve my problem without leaking references. That's neat, gonna do that.
In my scenario I had to pass down
Single.just(Unit)
because it was a
Single
, which admits no
empty()
state. Little less neat, works nonetheless
­čĹŹ 2