Skip to content

Commit

Permalink
fix readme typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Osid Abu-Alrub authored and Osid Abu-Alrub committed Jul 20, 2022
1 parent ff48df1 commit dd521c7
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
![Maven Central](https://maven-badges.herokuapp.com/maven-central/me.kisoft/easybus-core/badge.png)

# EasyBus
Easy bus is a simple, event bus for java designed for simplicity and

Easy bus is a simple, event bus for java designed for simplicity and
java practices in mind

* Annotation-Based
* Sync and Async
* Auto-Registration of Events
* Compile-Time checking for events & handlers
- Annotation-Based
- Sync and Async
- Auto-Registration of Events
- Compile-Time checking for events & handlers

# Usage

# Useage
## Installation

To use the easybus, add the following into your pom.xml

```xml
<dependency>
<groupId>me.kisoft</groupId>
Expand All @@ -24,10 +29,12 @@ If you want to use a specific backing implementation of easybus, you can also im
that specific implementation which will also import easybus

## Defining Events and Handlers
Afterwards, you will need to define your events and handlers using the ```@Handle```
and ```@Event``` annotations

Afterwards, you will need to define your events and handlers using the `@Handle`
and `@Event` annotations

### Defining Events

```java
@Event
public class MyEvent{
Expand All @@ -37,6 +44,7 @@ public class MyEvent{
```

### Defining Handlers

```java
@Handle(event=MyEvent.class)
public class MyEventHandler{
Expand All @@ -46,30 +54,33 @@ public class MyEventHandler{
}
```

Note that the `handle(MyEvent event)` method is mandatory, and it is the method that will be called by the event bus. The Method **MUST** be called `handle` and have the same type as your target event.

Note that the ```handle(MyEvent event)``` method is mandatory, and it is the method that will be called by the event bus. The Method **MUST** be called ```handle``` and have the same type as your target event.
### Adding Events and Handlers
You must also create a new event bus and specify the packages or classloaders your
events are in

You must also create a new event bus and specify the packages or classloaders your
events are in

```java
EasyBus bus = new EasyBus();
bus.search("my.package.name")
.search("my.second.package");
```


You will probably need to wrap the event bus as a singleton or maintain some reference to it, but that is just you coding.

### Posting Events

```java
bus.post(new MyEvent());
```

### Async Handlers
Async Handlers are defined in the same way as handlers, except that they run

Async Handlers are defined in the same way as handlers, except that they run
in a seperate thread from the current thread. This is more of a hint to the backing bus;
its not mandatory to honor async execution.

```java
@Handle(event=MyEvent.class,async=true)
public class MyEventAsyncHandler{
Expand All @@ -81,7 +92,6 @@ public class MyEventAsyncHandler{

## Implementing a Backing Bus

To implement a backing bus, all you need to do is implement the ```me.kisoft.easybus.Bus``` Interface, and when
creating a new EasyBus, you need to use the ```new EasyBus(Bus bus)``` constructor to change the backing bus, or
To implement a backing bus, all you need to do is implement the `me.kisoft.easybus.Bus` Interface, and when
creating a new EasyBus, you need to use the `new EasyBus(Bus bus)` constructor to change the backing bus, or
create your own factory

0 comments on commit dd521c7

Please sign in to comment.