The meaning of "_subscriptions.add(tapEventEmitter.connect());"?
fantianwen opened this issue · comments
this is a segment of class RxBusDemo_Bottom3Fragment appears about line 77
and ,I want to know why it wrote like that,and whether that:
could
_subscriptions.add(tapEventEmitter.connect());
be replaced by only
tapEventEmitter.connect();
as I only want to emmit the items to its subscribers
Thank you very much ! :)
why it wrote like that,
_subscriptions.add(tapEventEmitter.connect());
the advantage with adding it to _subscriptions
is so that, when we exit the fragment/activity we can dispose off the subscriptions by unsubscribing. Have a look at line 84 where we do this onStop
.
as I only want to emmit the items to its subscribers
I don't entirely understand what you mean here, but you technically are only emitting the "event"s to your subscribers. So that shouldn't be an issue.
Glad to help. I'm closing this issue, feel free to re-open if you have clarifications. Cheers!