https://github.com/rfresh2/simpleeventbus
Minimal Java EventBus without reflection
https://github.com/rfresh2/simpleeventbus
Last synced: over 1 year ago
JSON representation
Minimal Java EventBus without reflection
- Host: GitHub
- URL: https://github.com/rfresh2/simpleeventbus
- Owner: rfresh2
- License: mit
- Created: 2024-01-21T22:20:52.000Z (over 2 years ago)
- Default Branch: mainline
- Last Pushed: 2024-04-22T19:23:35.000Z (about 2 years ago)
- Last Synced: 2024-04-24T12:04:06.424Z (about 2 years ago)
- Language: Java
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleEventBus
Minimal, High Performance Java EventBus
# Features
* Minimal API, no reflection or annotations processing
* Asynchronous and Synchronous Event Dispatching
* Event Priorities
* Cancellable Events
## Why?
Typical Java Event Buses use annotations and reflection to subscribe or invoke event handlers
I use [GraalVM native image](https://www.graalvm.org/) in projects like [ZenithProxy](https://github.com/rfresh2/ZenithProxy)
Using GraalVM with reflection is painful as each reflective call [needs to be specified in a metadata file](https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection) at build time
# Usage
## Add Dependency
### Gradle
Groovy:
```groovy
repositories {
maven { url 'https://maven.2b2t.vc/releases' }
}
dependencies {
implementation 'com.github.rfresh2:SimpleEventBus:1.4'
}
```
Kotlin:
```kotlin
repositories {
maven("https://maven.2b2t.vc/releases")
}
dependencies {
implementation("com.github.rfresh2:SimpleEventBus:1.4")
}
```
### Maven
```xml
maven.2b2t.vc
https://maven.2b2t.vc/releases
com.github.rfresh2
SimpleEventBus
1.4
```
## EventBus API
See [SimpleEventBus.java](https://github.com/rfresh2/SimpleEventBus/blob/mainline/src/main/java/com/github/rfresh2/SimpleEventBus.java)
Example usage: [SimpleEventBusTest.java](https://github.com/rfresh2/SimpleEventBus/blob/mainline/src/test/java/com/github/rfresh2/SimpleEventBusTest.java)
# Benchmarks
VS [LambdaEvents](https://github.com/lenni0451/LambdaEvents)
```
EventsBenchmark.callASM avgt 4 418591.445 ± 182333.340 ns/op
EventsBenchmark.callLambdaMetaFactory avgt 4 426080.459 ± 11000.081 ns/op
EventsBenchmark.callMethodHandles avgt 4 758218.763 ± 57466.156 ns/op
EventsBenchmark.callReflection avgt 4 563770.273 ± 33414.060 ns/op
EventsBenchmark.callSimpleEventBus avgt 4 371913.931 ± 20369.029 ns/op
```