<dependencies>
<dependency>
<groupId>io.cronus</groupId>
<artifactId>cronus-core</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
import io.cronus.Cronus;
import io.cronus.Event;
import io.cronus.EventHandler;
public class MyLib implements Cronus {
private EventHandler eventHandler;
public MyLib() {
eventHandler = new EventHandler();
eventHandler.register(MyEvent.class, event -> {
System.out.println("Event received: " + event.getName());
});
}
public void sendEvent(String name) {
MyEvent event = new MyEvent(name);
eventHandler.publish(event);
}
private static class MyEvent implements Event {
private String name;
public MyEvent(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}
public class MyApp {
public static void main(String[] args) {
MyLib myLib = new MyLib();
myLib.sendEvent("Hello, Cronus!");
}
}