Skip to content
DaanVanYperen edited this page Sep 15, 2014 · 1 revision

Cancelling events

Make cancellable event

Implement Cancellable interface.

public class CancellableEvent implements Event, Cancellable {
    private boolean cancelled;
    public boolean isCancelled() { return cancelled; }
    public void setCancelled(boolean value) { cancelled = value; }
}

Cancel events

Toggle cancelled on event.

@Subscribe
public void handleMyEvent( CancellableEvent event ) {
   event.setCancelled(true); 
}

Ignore cancelled events

/** Will not be called by cancelled event. */
@Subscribe(ignoreCancelledEvents=true)
public void handleMyEvent( CancellableEvent event ) { .. }