Clockwork

Clockwork is a TypeScript-first, modular game engine workspace focused on ECS-driven runtime systems and a WebGL2 renderer stack.

Event Bus

# Event Bus

qti-clockwork-events provides typed buffered and immediate event channels.

Core API

  • send(event) or send(type, event)
  • sendImmediate(event) or sendImmediate(type, event)
  • listen(type): Events<T>
  • on(type, listener): unsubscribe
  • clear(type?)

Buffered vs Immediate

  • send appends to per-type buffer
  • sendImmediate invokes listeners instantly and does not buffer

Type Inference Rules

Implicit type inference only works for non-primitive class-instance events.

For primitives/plain objects use explicit channel:

events.send(DamageSymbol, { target: 1, amount: 5 })

Clockwork JVM example:

import com.quietterminal.clockwork.ClockworkApp;

record DamageEvent(long target, int amount) {}

ClockworkApp app = new ClockworkApp().build();
app.world().events().subscribe(DamageEvent.class, e ->
    System.out.println("damage=" + e.amount() + " target=" + e.target())
);
app.world().events().emit(new DamageEvent(1L, 5));
app.shutdown();

Events Snapshot

Events<T> is immutable for a read call and exposes:

  • iter()
  • isEmpty()
  • len()
Last updated: March 05, 2026