Skip to content

Cuubicc/Esys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Esys

An event bus for java designed to be easy to use, fast and yet flexible. Work is still in progress.

Create an EventBus

To create a default event bus with a name:

import org.cubic.esys.EventBus;

public class App {

    public static final EventBus EVENT_BUS = EventBus.buildDefault("the event bus");
}

Subscribe to objects and classes

Subscribing to objects:

import org.cubic.esys.EventBus;

public class App {

    public static final EventBus EVENT_BUS = EventBus.buildDefault("the event bus");

    public static void main(String[] args) {
        // our object we want to subscribe to
        App app = new App();
        EVENT_BUS.subscribe(app);
        EVENT_BUS.unsubscribe(app);
    }
}

Subscribing to classes:

import org.cubic.esys.EventBus;

public class App {

    public static final EventBus EVENT_BUS = EventBus.buildDefault("the event bus");

    public static void main(String[] args) {
        EVENT_BUS.subscribe(App.class);
        EVENT_BUS.unsubscribe(App.class);
    }
}

Listeners

A simple example:

import org.cubic.esys.EventBus;
import org.cubic.esys.Subscribe;

public class App {

    public static final EventBus EVENT_BUS = EventBus.buildDefault("the event bus");

    public static void main(String[] args) {
        EVENT_BUS.subscribe(App.class);
        EVENT_BUS.unsubscribe(App.class);
    }

    @Subscribe
    public static void onEvent(SomeEvent event) {
        // handle the event...
    }
}

Posting events

import org.cubic.esys.EventBus;

public class App {

    public static final EventBus EVENT_BUS = EventBus.buildDefault("the event bus");

    public static void main(String[] args) {
        Event e = new Event(); // some event we want to post
        EVENT_BUS.post(e);
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages