Tiny and fast pubsub implementation with subscriber priorities and event canceling for Java.
void run() {
Bus bus = new Bus();
bus.reg(Sub.of(String.class, System.out::println));
bus.pub("Hello World!");
}
class Listenable {
Sub<Long> sub = Sub.of(Long.class, l -> Foo.bar(l));
void run() {
Bus bus = new Bus();
bus.reg(this);
bus.pub(42L);
}
}
For more explanation, check the example .