guava icon indicating copy to clipboard operation
guava copied to clipboard

Make the use of @Subscribe annotation optional for the EventBus handlers

Open Villason opened this issue 9 years ago • 1 comments

Some of us need to create a bus implementing given interfaces we cannot change. The use of the @Subscribe annotation makes it very difficult to implement the interfaces.

Not working example:

public interface Bus {
    <T extends Message> void send(T message);
    void register(Handler handler);
}
public interface Handler<T extends Message> {
    void handle(T message);
}
public class GuavaBus implements Bus {
    private EventBus eventBus;

    GuavaBus() {
        eventBus = new EventBus();
    }

    @Override
    public <T extends Message> void send(T message) {
        eventBus.post(message);
    }

    @Override
    public void register(Handler handler) {
        eventBus.register(handler);
    }
}

Villason avatar Jan 01 '17 15:01 Villason

It's not clear to me what you're asking for. If this is still something you need, please reopen and try to explain more clearly what it is that you need to do and what you think eventbus needs to do differently to support that.

cgdecker avatar Jul 30 '19 20:07 cgdecker