A bloat-free library for dispatching and receiving events.
EventLibrary contains the following features:
- dispatch events (synchronously and asynchronously)
- register (anonymous) listeners for events
- provide your custom implementations to process events however you want
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/SteveOberst/EventLibrary")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv().get("GITHUB_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv().get("GITHUB_TOKEN")
}
}
}
dependencies {
implementation group: "net.sxlver.eventlibrary", name: "core", version: "<latest>"
}
No need for initialization! The Framework is mostly based off of static access, so no need to store any references.
final MyEvent event = new MyEvent();
final IEventResult<MyEvent> result = EventLibrary.dispatchEvent(event);
public class MyListener {
@EventSubscriber
public IListenerExecutionResult<MyEvent> onEvent(final MyEvent event) {
//...
return ListenerExecutionResult.success(event);
}
}
public class Main {
public static void main(String[] args) {
EventLibrary.registerListener(new MyListener());
}
}
final IEventHandler<MyEvent> handler = EventLibrary.registerListener(event -> {
//...
return ListenerExecutionResult.success(event);
, MyEvent.class})
To get started with the framework make sure to checkout the Examples and Docs
Released under the MIT License.