GameEventBus class

Lightweight typed pub/sub bus bridging gameplay events (fired from a Flame Component/game loop) to business-logic services (EconomyWallet, AchievementService, AnalyticsProvider, ...) that want to react to them — without every new event type requiring a manual wire-up at each interested service.

Entirely optional: nothing in this package requires a GameEventBus to exist. A game built on RoyGame that never creates one behaves exactly as before.

Constructors

GameEventBus()

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any subscribe call's returned StreamSubscription is still listening (i.e. hasn't been cancelled and the bus hasn't been disposed). Exists so a caller/test can prove a subscription was actually released on teardown, rather than only inferring it from emit silently no-oping after dispose (BUG-93).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → Future<void>
Closes the underlying stream. Call from the owner's dispose().
emit(GameEvent event) → void
Emits event to every current subscriber whose type matches. A no-op once dispose has run — a gameplay callback racing a screen's own teardown shouldn't crash on a stale bus reference.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subscribe<T extends GameEvent>(void onEvent(T event), {void onError(Object error, StackTrace stackTrace)?}) → StreamSubscription<GameEvent>
Subscribes to events of type T (or a subtype). If onEvent throws, the error is caught and passed to onError (if given) rather than rethrown — one failing subscriber never crashes the bus or any other subscriber.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited