0

I'm trying to post an event from within a subscriber

@Subscribe
public void onFirstEvent(FirstEvent event) {
    ...
    bus.post(new SecondEvent(...));
}

And in my other class, where I handle SecondEvent, I use a subscribe method in the same way. The problem is, the method that subscribes to SecondEventis called even before onFirstEvent() is called.

What am I doing wrong?

stack
  • 225
  • 4
  • 12

1 Answers1

0
public void onFirstEvent(Event event) {
    if (event instanceof FirstEvent) {
        ...
        bus.post(new SecondEvent(...));
    } else if (event instanceof SecondEvent) {
        // process
    }

}

you can test like this

shilu
  • 1
  • 1
  • How will this solve the problem? You mean I remove the SecondEVent subscriber method, and handle it within onFirstEvent itself? – stack Apr 01 '17 at 09:44