https://github.com/x4e/eventdispatcher
A Kotlin implementation of Event Driven Architecture
https://github.com/x4e/eventdispatcher
Last synced: 10 months ago
JSON representation
A Kotlin implementation of Event Driven Architecture
- Host: GitHub
- URL: https://github.com/x4e/eventdispatcher
- Owner: x4e
- License: mit
- Created: 2019-12-17T13:47:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-09T12:59:47.000Z (almost 6 years ago)
- Last Synced: 2025-04-30T20:35:13.369Z (about 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 88.9 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EventDispatcher
A Kotlin implementation of Event Driven Architecture.
Example usage:
build.gradle:
```Groovy
repositories {
maven {
url 'https://jitpack.io'
}
}
dependencies {
compile 'com.github.cookiedragon234:EventDispatcher:master-SNAPSHOT'
}
```
Kotlin:
```Kotlin
data class ExampleEvent(var str: String)
object Test {
init {
EventDispatcher.register { event: ExampleEvent ->
println("Event Received!")
event.str = "b"
}
with (ExampleEvent("a")) {
EventDispatcher.dispatch(this)
println(str) // "b"
}
}
}
```
Java:
```Java
public class Test {
static class Event {
public String str;
public Event(String str) {
this.str = str;
}
}
static {
EventDispatcher.register(Event.class, event -> {
System.out.println("Event Received!");
event.str = "b";
return Unit.INSTANCE;
});
Event event = new Event("a");
EventDispatcher.dispatch(event);
System.out.println(event.str); // "b"
}
}
```