DSpotDevelopers / declex

DecleX - Declarative Framework for Android, easier and faster coding.
Other
168 stars 25 forks source link

Before fail an event, try to run it in the next round of the UI #189

Open smaugho opened 7 years ago

smaugho commented 7 years ago

It is a common situation to call some interface (ex, another activity), specially when integrating 3rd party services, and this activity will return running some Callback. Typically this callback is called before the onResume method, so EventBus hasn't been registered and the events sent from the Callback are not handled by the app.

To prevent this, typically something like this is done:

$UIThread();
$SomeEvent();

This solves the issue many times, but not always.

A general solution would be to check if the interface has been registered to listen the event, if not, then to post the event sticky, when the interface is registered with event bus, it can check the Sticky events, and dispatch the methods.