EventBus
EventBus copied to clipboard
Post events delayed
It would be nice, if it is possible so send events with a delay and the possibility to cancel them
You can build around this by using android.os.Handler.postDelayed()
yeah, you can do this, but it can be handy if it is implemented in the frame work :)
With canceling you are referring to cancel delayed events, that were yet not send?
yes
As proposed in the issue #193, I think delayed events would be useful. As an example, let's say I use an asynchronous API. I start a request and then I wait for the the asynchronous response. The operation can take some time or never return if an error occurs.
In the API response callback, I generate an event with the result, but this operation can take some time. An idea would be to send a delayed event when making the API request and use it as a timeout. If I receive the response event before the delayed event, this means an error occurred and it should be possible to cancel the delayed event (like sticky events).
Is something do you plan to implement ? If no, which alternative could you propose to schedule timeouts and cancel them with ease ?
@metc You might want to have a look at RxJava. -ut
Now that Eventbus is not only for Android, it is good idea to have post delayed solution that works on Android and 'normal' Java (server) apps. In my case, I have shared Eventbus code between the two, which mean two ugly impl as a work around.