Subscribers¶
Definition¶
To define a subscriber, you have multiple options.
Extend the Subscriber class:
Implement the ISubscriber interface:
Subscription¶
Once you've defined your subscriber, you can subscribe it to an event bus in a variety of ways.
Inside the subscriber itself.
public class Consts {
private static final IEventBus EVENT_BUS = new EventBus();
}
public class ExampleSubscriber extends Subscriber {
public ExampleSubscriber() {
Consts.EVENT_BUS.subscribe(this);
}
}
public class Consts {
private static final IEventBus EVENT_BUS = new EventBus();
}
public class ExampleSubscriber extends Subscriber {
public ExampleSubscriber() {
}
public void subscribe() {
Consts.EVENT_BUS.subscribe(this);
}
}
Or externally.