Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: EventBus

[15:7] extends: FxObj

Wraps FXGL's EventBus, the synchronous JavaFX-based event dispatcher used across the engine. Aussom users construct one directly or reach the engine instance through the FXGL DSL. Events are JavaFX Event subclasses identified by their EventType. addEventHandler returns a Subscriber that can be unsubscribed later or via removeAllEventHandlers.

Methods

  • EventBus (Ajo = null)

    Creates an EventBus wrapper. With no argument constructs a new FXGL EventBus; with an AussomJavaObject wraps an existing one (used by fxgl.getEventBus).

    • @p Ajo is an optional AussomJavaObject around an FXGL EventBus.
  • adopt (object Ajo)

    Wraps an existing EventBus AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an EventBus.
    • @r A new wrapper.
  • addEventHandler (object EventType, callback Handler)

    Registers an EventHandler for the given EventType. Returns a Subscriber whose unsubscribe method detaches the handler.

    • @p EventType is an AussomJavaObject around a javafx.event.EventType.
    • @p Handler is a callback that takes the event as its argument.
    • @r An AussomJavaObject wrapping a Subscriber.
  • removeEventHandler (object EventType, object Handler)

    Removes a previously registered handler for the given EventType.

    • @p EventType is the same EventType passed to addEventHandler.
    • @p Handler is the same AussomJavaObject returned by aji.closure.
    • @r this object
  • removeAllEventHandlers ()

    Unsubscribes every handler this bus currently holds.

    • @r this object
  • fireEvent (object Event)

    Fires the given Event synchronously to every matching handler.

    • @p Event is an AussomJavaObject around a javafx.event.Event.
    • @r this object
  • setLoggingEnabled (bool Enabled)

    Sets whether debug logging is enabled for fired events.

    • @p Enabled is a bool.
    • @r this object