Let's say my App wants to fetch some data from the internet, and it does so through an AsyncTask. When this task finishes, it posts an event with the response data to the EventBus.
The AsyncTask may be triggered either via a Service or an UI. If an UI triggers it, then, before starting the fetch request, a modal dialog is created, indicating that the download is being performed.
How do I manage the lifetime of the dialog? When the result comes in via an EventBus event, I know that I can close the dialog. Should the download fail, I would then need to publish an event specifically for the originator to close the dialog?
Doesn't this coupling somehow diminish the benefit of using EventBus?
How would I go about this, so that I don't have to publish a "close dialog" event? Move the dialog creation/destruction into the AsyncTask?
Is there a pattern that deals with this issue?