Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 893 Bytes

readme.md

File metadata and controls

35 lines (28 loc) · 893 Bytes

Example:

public class Main implements Listener {

    private EventManager manager = new EventManager();

    public void start() {
        manager.registerListener(this);
        TestEvent event = new TestEvent();
        manager.invokeEvent(event);
        PreExitTestEvent event1 = new PreExitTestEvent();
        manager.invokeEvent(event1);
        if (event1.isCancelled()) {
            manager.clear();
            start();
        }
        return;
    }

    private final Reactor<?> onTest = new Reactor<TestEvent>(e -> {
        System.out.println("Nice! " + e.getTimeReacted());
    }).register(this);

    private final Reactor<?> onExit = new Reactor<PreExitTestEvent>(e -> {
        Random random = new Random();
        e.setCancelled(random.nextBoolean());
    }).register(this);

    public static void main(String[] args) {
        new Main().start();

    }
}