Which GWT EventBus should I use?

后端 未结 4 1667
时光取名叫无心
时光取名叫无心 2021-02-18 16:43

In the gwt-user.jar there are 2 EventBus interfaces and SimpleEventBus implmentations.

com.google.gwt.event.shared.EventBus and com.google.web.bindery

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-18 17:37

    I know this question has already an answer but might be worth while adding the following. As I said in my comment above, Activity still needs the com.google.gwt.event.shared.EventBus class. To avoid deprecated warnings, I did the following (I use GIN):

    public class GinClientModule extends AbstractGinModule {
    
        @Override
        protected void configure() {
            bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
            ...
        }
    
        @Provides
        @Singleton
        public com.google.gwt.event.shared.EventBus adjustEventBus(
                EventBus busBindery) {
            return (com.google.gwt.event.shared.EventBus) busBindery;
        }
    
    ...
    

    By doing this, you will always be using the object from the "new" version of Event bus in the bindery package.

提交回复
热议问题