Skip to content

How to use EventBroker

chqu1012 edited this page May 31, 2019 · 1 revision

First steps to use EventBroker:

  • Initialize EmfWorkbenchContext.init(); it contains the BaseModule, which include the EventBroker to the Dependency Container
  • The object which subscribe the EventBroker should be registered like IEventBroker#register(Object)
  • To subscribe the Event a method with @Subscribe annotation should be implemented. This method handle with a topic and an input.
public void onOpenEditor(EventContext context){
  if(context.getTopic()== EventTopic.SELECTION){
   // React on selection topic
  }else if(context.getTopic()== EventTopic.OPEN_EDITOR){
   // React on open editor topic
  }
}
  • To send an event to EventBroker, the EventBroker#post(EventContext) should be called with a parameter of EventContext. This contains the selected topic and the input if it is required.
Clone this wiki locally