I have a requirement where a service needs to be able to cancel a network request when all subscribers have unregistered from a specific event. I am using Greenrobot EventBus and as far as I can tell there is nothing built in that will send an event whenever someone unregisters. I was thinking that I could override the EventBus's unregister method and post an 'UnsubscribedEvent' whenever it is called. The service can then listen to this event and when it receives it it can call hasSubscriberForEvent to check whether it should cancel the request. Does this sound reasonable or does anyone have any better suggestions?
Aucun commentaire:
Enregistrer un commentaire