vaadin4spring icon indicating copy to clipboard operation
vaadin4spring copied to clipboard

Question related to @EnableEventBus

Open turgos opened this issue 7 years ago • 2 comments

I am using 2.0.0.RELEASE.

I have seen that you did not use @EnableEventBus at your eventbus-sample.

instead you used: @Autowired EventBus.ApplicationEventBus applicationEventBus;

/**

  • Forward {@link org.springframework.context.ApplicationEvent}s to the {@link org.vaadin.spring.events.EventBus.ApplicationEventBus}. */ @Bean ApplicationContextEventBroker applicationContextEventBroker() { return new ApplicationContextEventBroker(applicationEventBus); }

Is that the preferred way?

turgos avatar Mar 25 '17 15:03 turgos

Also, I could not make @EventBusListenerMethod annotation make work.

When I mark my methods with that annotation (for example @EventBusListenerMethod(scope = EventScope.UI, filter = LoginEventFilter.class) ), even if event published successfully, method is never invoked.

if it is possible, can you give an example.

turgos avatar Mar 26 '17 19:03 turgos

Looks like EventBusListenerMethodFilter filter method is changed. When I change my Filters as below example, @EventBusListenerMethod annotated methods called fine.

import org.vaadin.spring.events.Event;
import org.vaadin.spring.events.EventBusListenerMethodFilter;

public class BrowserResizeEventFilter implements EventBusListenerMethodFilter {
  @Override
  public boolean filter(Event<?> event) {

    if (BrowserResizeEvent.class.isAssignableFrom(event.getPayload().getClass()))
      return true;
    else
      return false;
  }
}

So, looks like everything works fine. I appreciate if you still explain @EnableEventBus annotation and where/when to use it.

turgos avatar Mar 28 '17 12:03 turgos