Train Dispatch Board is a terminal app that renders a UK railway station departure board.
Each train is a worker thread running its own journey state machine. The main thread is the dispatch controller and renderer.
It exists to show how postal’s MessagePort transport makes cross-thread Node.js communication feel like normal pub/sub.
The main thread calls connectToWorkerThread(worker) and each worker calls connectFromWorkerThread().
After the handshake, addTransport() wires postal’s message bus across the thread boundary.
Eight workers publish independently — the main thread sees all of it through a single wildcard subscription.
Wildcard subscriptions
The main thread subscribes to train.# to capture status and position messages from every train.
The dispatch controller subscribes per-train to dispatch.<id>.* for hold, clear, and platform commands.
AMQP-style topic matching routes messages without any coupling between producers and consumers.
Bidirectional messaging
Workers publish status updates. The main thread publishes dispatch commands back — hold, platform reassign, clear.
Both directions flow over the same MessagePort transport. Workers react to commands mid-journey,
demonstrating that postal transports are full-duplex by default.
Wiretap observability
A wiretap on the main thread captures every envelope that flows through the bus and feeds the dispatch log.
Nothing is filtered — the log shows the raw pub/sub traffic as it happens, demonstrating
how wiretaps provide observability without modifying publishers or subscribers.
When a train departs, the main thread recycles the board row: it pulls the next destination from a shuffled pool of 24 UK cities, spawns a fresh worker, and the split-flap animation cascades the new departure into the vacated slot.