Guava Custom EventBus Example

Guava Custom EventBus Example

Last tutorial you saw how to use Google Guava EventBus after registering subscriber. In this example we will create CustomEventBus class which will extend EventBus class and will use its register method inside constructor to register subscriber. As this CustomEventBus class will be center point of registering all component and can be found out easily:

  • CustomEvent.java:

  • EventHolder.java:

  • EventSubscriber1.java:

  • EventSubscriber2.java:

  • EventPublisher.java:

  • Output: Run EventPublisher.java you will see below output:

Guava Custom EventBus Example

  • For more information please visit Google Guava library here

Leave a Reply

Your email address will not be published. Required fields are marked *