An open API service indexing awesome lists of open source software.

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

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
```