Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 676 Bytes

README.md

File metadata and controls

30 lines (25 loc) · 676 Bytes

Event System

simple annotation based event system

Usage

CustomEvent.java

public class CustomEvent() extends Event {}

Main class

// in ur start method or similar
private EventManager eventManager = EventManager.getInstance();
eventManager.register(new EventListener()); // Replace with ur class where the event should be called

// when u want to call the event
eventManager.fire(new CustomEvent(data));

EventListener.java

public class EventListener {
    // listening for the event
    @Subscribe(target = CustomEvent.class)
    public static void onCustomEvent(CustomEvent event) {
        // event triggered code
    }   
}