Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/xhyrom/mashe

Simple, fast, and easy to use EventBus for Java
https://github.com/xhyrom/mashe

bus emitter event handler java listener

Last synced: 27 days ago
JSON representation

Simple, fast, and easy to use EventBus for Java

Awesome Lists containing this project

README

        

# Mashe

Simple, fast, and easy to use Event Handling for Java.

## Usage

```java
import hyro.mashe.Mashe;
import hyro.mashe.types.Event;
import hyro.mashe.annotations.Listen;

public class Example {
public static void main(String[] args) {
// Create a new mashe
Mashe mashe = new Mashe();

// Register a listener (you can also use annotations)
mashe.register(ExampleEvent.class, (event) -> {
System.out.println("Hello World!");
});

// Register events with Listen annotation
new ExampleV2().start(mashe);

// Post an event
mashe.fire(new ExampleEvent());
}
}

public class ExampleV2 {
public void start(Mashe mashe) {
mashe.register(this);
}

@Listen
public void onExampleEvent(ExampleEvent event) {
System.out.println("Hello World with annotations!");
}
}

public class ExampleEvent extends Event {
// ...
}
```

## Imports
With [jitpack](https://jitpack.io/#xHyroM/mashe)
> You can also use github packages but you need have github personal token

### Maven

```xml


jitpack.io
https://jitpack.io

com.github.xHyroM
mashe
v0.1.1

```

### Gradle

```groovy
repositories {
maven { url 'https://jitpack.io' }
}

dependencies {
implementation 'com.github.xHyroM:mashe:v0.1.1'
}
```