EventBus icon indicating copy to clipboard operation
EventBus copied to clipboard

Post events delayed

Open alosdev opened this issue 10 years ago • 7 comments

It would be nice, if it is possible so send events with a delay and the possibility to cancel them

alosdev avatar Mar 14 '14 09:03 alosdev

You can build around this by using android.os.Handler.postDelayed()

jnagels avatar Jun 05 '14 11:06 jnagels

yeah, you can do this, but it can be handy if it is implemented in the frame work :)

alosdev avatar Jun 06 '14 07:06 alosdev

With canceling you are referring to cancel delayed events, that were yet not send?

greenrobot avatar Jun 06 '14 08:06 greenrobot

yes

alosdev avatar Jun 06 '14 08:06 alosdev

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 avatar Jul 14 '16 19:07 metc

@metc You might want to have a look at RxJava. -ut

greenrobot-team avatar Jan 09 '17 08:01 greenrobot-team

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.

ramiws avatar Jan 28 '18 10:01 ramiws