Events
What fires when, in what order, on which bus.
The reels only move symbols. Everything a player actually hears and reads during a spin, the whoosh as the columns take off, the thunk as each one lands, the drumroll when the last reel hesitates, the button that turns from "spin" into "skip", the win counter that starts rolling, all of that is built by you, outside the library. For that to work the engine has to tell you what is happening, at the exact moment it happens, without you polling it every frame or guessing from timers.
That is what events are for. Every moment that matters inside a spin is announced on a typed emitter, with a payload that carries the facts you need (which reel, which symbols, which result). You subscribe with reelSet.events.on('spin:complete', fn) and the TypeScript types tell you what fn receives. There are fifty-nine such names on the set, grouped by prefix (spin:, skip:, pin:, cascade: and so on), seven more on each individual reel, and a separate thirteen on a Hold & Win board. The rest of this page says which fires when, in what order, and how to use them.
Wiring a HUD and audio
Before the detailed timeline, here is how to think about the two things almost every game wires first. A HUD cares about state: is the board spinning, can the button be pressed, what did the spin produce. Audio cares about moments: a sound has to start at the instant a reel hits its frame, not a bounce later. The set bus gives you both, and the trick is matching each to the event that fires at the right instant.
The table below is a starting map from "what the player experiences" to the event to listen for. Two words of vocabulary first. A tease (the library calls it anticipation) is a reel that slows down and holds before stopping, for drama; a skip is the player pressing the button mid-spin, which the engine turns into either a slam (every reel lands this frame) or a quicken (the delays are cut, the landing still plays).
| The player experiences | Listen for | What to do there |
|---|---|---|
| The spin starts | spin:start | Disable the spin button or turn it into a skip button. Start the reel loop sound. In a cascade this fires again on every refill, so a counter keyed on it counts stages, not spins. |
| Every reel is moving | spin:allStarted | The staggered kickoff is over. A good moment to fade in the loop fully or start a "waiting for result" timer in your own code. |
| A reel is about to tease | anticipation:reel | Start the drumroll or heartbeat and show the anticipation glow on that reel. The payload tells you its order in the tease sequence and how many will tease in total. |
| A reel hits its result frame | spin:reelLanding | Play the landing thunk. This fires the instant the symbols are in place and before the bounce, which is where the sound feels right. It fires again on every cascade stage. |
| A reel is fully at rest | spin:reelLanded | Light up a scatter that just landed, or count landed reels. One bounce later than reelLanding on an animated stop, the same tick on a slam. |
| The whole spin is over | spin:complete | Stop the loop sound, read result.symbols to evaluate wins, re-enable the button. Everything the HUD needs about the outcome is in the SpinResult payload. |
| The player pressed skip | skip:requested, skip:completed | Play the skip whoosh on requested; wait for completed before you treat the reels as settled. A quicken completes when its last freed reel lands, a slam completes the same tick. |
| The speed changed | speed:changed | Update the turbo indicator. The round-end restore after a skip boost comes through here too, so the indicator follows the real profile. |
Two patterns cover most of the HUD. The spin button is one control with two meanings, and isSpinning is enough to pick between them. The server round trip happens while the reels are already moving: you call spin(), fetch, then hand the grid to setResult(), which is what releases the stop. If the player skipped before the result arrived, the engine queues that press (skip:queued) and applies it the moment the result lands.
Use isSpinning to branch the same button between "start" and "skip".
button.addEventListener('click', () => {
if (reelSet.isSpinning) reelSet.skip();
else reelSet.spin();
});Real slots fetch the server answer while the reels are spinning, then call setResult() to release the stop.
const p = reelSet.spin();
const r = await fetch('/spin').then(x => x.json());
reelSet.setAnticipation(r.anticipationReels);
reelSet.setResult(r.symbols);
await p;One spin, in landing order
The two figures that follow are the backbone of this page: one spin, laid out as a swimlane, with time flowing down. The left lane is you, the caller. The middle lane is the set bus, reelSet.events. The right lane is one reel's own bus, reel.events, where you can see the reel moving through its phases (start, spin, maybe anticipation, stop), each announced by a phase:enter and a phase:exit. Boxes carry only the event name; the payloads are in the big table further down.
Figure 1 runs from your spin() call to the moment the result arrives. Notice three things: your skip press can land anywhere after spin:start; symbol:created fires on the reel bus once per wrap (a symbol scrolling off one edge and being reused at the other, which is how the strip loops); and setResult() is the gate, because nothing can stop until the engine knows what to land on.
Figure 2 picks up at the first stop and runs to spin:complete. The dashed window is the part that repeats: once per reel, in stop order, and again on every cascade stage. Look at the two arrows crossing from the reel lane into the set lane. The solid one is the reel's landing being relayed as spin:reelLanding at the frame the symbols arrive, before the bounce. The dashed one is landed becoming spin:reelLanded one bounce later, when the reel is truly at rest. On a slam the two happen in the same tick. Reels you asked the engine to hold still (holdReels) skip the window entirely.
Three buses
Figure 3 shows how the channels relate. Each reel's bus is private to that reel and feeds the set bus in exactly one place: the spin controller listens to every reel's landing and landed and re-emits them on the set bus with the reel index added in front. Nothing else is relayed, so the two buses never duplicate each other. The Hold & Win board bus stands apart: it is its own emitter with its own vocabulary, never relayed to or from the others. And because a BoardGrid cell is a complete one-cell ReelSet, every cell on a board also carries the two buses on the left.
Every ReelSet event
This is the full reference for the set bus, and the table you will come back to long after the rest of the page is familiar. It is grouped by prefix, in roughly the order the features appear in a game: the core spin first, then teases and skips, then the presentation layers, then the board-reshaping and cascade features that most games never touch.
How to read it: the payload column is the tuple your listener receives as its arguments, so [reelIndex, symbols] means fn(reelIndex, symbols) and [] means the listener takes no arguments. Fires when is the exact instant and any caveats. Emitted from is the file and method under packages/pixi-reels/src/, for when you want to read the source around it. You do not need the last column to use the event.
| Event | Payload | Fires when | Emitted from |
|---|---|---|---|
| spin (7) | |||
| spin:start | [] | A spin or a cascade refill begins. Each refill emits it again, so a refill counts as a new round. | spin/SpinController.ts spin(), refill() |
| spin:allStarted | [] | Every non-held reel has started. | SpinController.ts _announceAllStartedIfReady |
| spin:stopping | [reelIndex] | The controller has asked this reel to stop. Never fires for held reels. | SpinController.ts _startReel |
| spin:reelLanding | [reelIndex, symbols] | The reel is on its result frame, every visible symbol had onReelLanded(), the bounce has not started. Fires on every landing path and is not deduplicated per spin. | relay of Reel.ts notifyLanded via SpinController.attachReel |
| spin:reelLanded | [reelIndex, symbols] | The reel is fully at rest: one bounceDuration after spin:reelLanding on an animated stop, the same tick on a slam. | SpinController.ts _markLanded |
| spin:allLanded | [result: SpinResult] | The last reel is at rest. | SpinController.ts _finishSpin |
| spin:complete | [result: SpinResult] | Right after spin:allLanded, same function. | SpinController.ts _finishSpin |
| anticipation (3) | |||
| anticipation:reel | [{ reelIndex, order, total }] | A reel started its tease, after any stagger offset. Only for reels in the anticipation set whose effective hold is above 0. | SpinController.ts _startReel |
| anticipation:reelEnd | [{ reelIndex }] | A teasing reel landed. Fires just before that reel's spin:reelLanded. | SpinController.ts _markLanded |
| anticipation:segment | [{ reelIndex, index, total, speed, targetSpeed }] | One leg of a curve tease began. speed is a multiple of spinSpeed, targetSpeed the same in px/frame. Curve teases only. | spin/phases/AnticipationPhase.ts |
| skip (4) | |||
| skip:requested | [info: SkipInfo] | A press freed reels. reels excludes landed and held reels; partial is true if reels are still spinning afterwards; mode is slam or quicken. | SpinController.ts _quicken, _slamTargets |
| skip:completed | [info: SkipInfo] | The same press, once its reels are down: the same tick for a slam, when the last freed reel lands for a quicken. | SpinController.ts _slamTargets, _markLanded |
| skip:queued | [info: SkipContext] | requestSkip() arrived before the result. The press fires once the result arrives. | SpinController.ts requestSkip, carrySkip |
| skip:boosted | [{ previous, current }] | The first skip() of a standard-mode round switched to the fastest registered profile. Once per round; never for slamStop(), requestSkip() or cascade mode. The restore on the next spin() emits speed:changed instead. | SpinController.ts _applyRoundSideEffects |
| speed (1) | |||
| speed:changed | [profile, previous] | setSpeed() switched profiles, including the round-end restore after a boost. | core/ReelSet.ts setSpeed |
| spotlight (2) | |||
| spotlight:start | [positions: SymbolPosition[]] | spotlight.show() or cycle() began a highlight. | spotlight/SymbolSpotlight.ts |
| spotlight:end | [] | The spotlight was hidden. Only if it was active. | spotlight/SymbolSpotlight.ts |
| win (4) | |||
| win:start | [wins: readonly Win[]] | Once per show(), with the wins in display order (value descending by default). | wins/WinPresenter.ts |
| win:group | [win, cells] | One win is now being presented, before its win:symbol events. Draw lines and outlines here. | wins/WinPresenter.ts |
| win:symbol | [symbol, cell, win] | One event per cell per win per cycle, spaced by stagger. symbol is typed unknown. | wins/WinPresenter.ts |
| win:end | [reason: 'complete' | 'aborted'] | The presentation finished or abort() was called. Loser alpha is restored first. | wins/WinPresenter.ts |
| pin (6) | |||
| pin:placed | [pin: CellPin] | pin() registered a claim on a cell. | core/ReelSet.ts pin |
| pin:moved | [pin, from: { reel, cell }] | movePin() finished, or setColumn()/splitSymbol() shifted a pin with its symbol. | ReelSet.ts movePin, _setColumn |
| pin:expired | [pin, reason: 'turns' | 'explicit' | 'eval' | 'collision'] | A pin was removed: turns ran out, unpin() or a geometry change, an eval pin at spin:start, or a migration collision. | ReelSet.ts unpin, _migratePinsForReel, _onSpinLanded, _onSpinStart |
| pin:migrated | [pin, { fromCell, toCell, clamped, reelIndex }] | A MultiWays reshape moved the pin. | ReelSet.ts _migratePinsForReel |
| pin:overlayCreated | [pin, overlay] | A pooled overlay symbol was created for a pin while the reels move. | ReelSet.ts _ensurePinOverlay |
| pin:overlayDestroyed | [pin, overlay] | The overlay goes back to the pool: on spin:allLanded, unpin or replacement. | ReelSet.ts |
| shape and adjust (MultiWays only) (3) | |||
| shape:changed | [cellsPerReel: number[]] | setShape() recorded a target shape, before any geometry change. | ReelSet.ts setShape |
| adjust:start | [{ reelIndex, fromCells, toCells }] | The AdjustPhase began reshaping this reel. | SpinController.ts _applyReshape |
| adjust:complete | [{ reelIndex }] | The reshape finished. | SpinController.ts _applyReshape |
| reels, rows, column (5) | |||
| reels:added | [{ from, count }] | addReels() or an expand step. The reels are already in reelSet.reels and the mask covers them. | ReelSet.ts _addReels |
| reels:removed | [{ from, count }] | removeReels() finished. The reels are already destroyed. | ReelSet.ts removeReels |
| rows:added | [{ count, rows: number[] }] | addRows() finished. | ReelSet.ts addRows |
| rows:removed | [{ count, rows: number[] }] | removeRows() finished. | ReelSet.ts removeRows |
| column:set | [{ reelIndex, fromCells, toCells }] | setColumn(), splitSymbol() or resetColumns() changed one reel at rest. | ReelSet.ts _setColumn |
| expand (5) | |||
| expand:start | [{ from, to, steps }] | expand() validated its input and is about to add the first step. | ReelSet.ts expand |
| expand:stepAdded | [step: ExpandStep] | A step's reels exist; fires before the onStepAdded hook. | ReelSet.ts expand |
| expand:stepLanded | [step: ExpandStepLanded] | The step's spin landed; fires before onStepLanded. | ReelSet.ts expand |
| expand:complete | [result: ExpandResult] | Every step landed. | ReelSet.ts expand |
| expand:end | [reason: 'complete' | 'failed'] | Always fires, so it is the one place to restore UI. | ReelSet.ts expand |
| cascade (tumble) (15) | |||
| cascade:fall:start | [{ reelIndex }] | Once per reel per spin(). Never on refill(). | spin/phases/CascadeFallPhase.ts |
| cascade:fall:symbol | [{ symbol, view, reelIndex, cellIndex, duration, ease, distance, signal }] | Right before each symbol's fall tween. signal aborts on skip or slam. | CascadeFallPhase.ts |
| cascade:fall:end | [{ reelIndex }] | Every view is at alpha 0. Only fires if :start fired. | CascadeFallPhase.ts |
| cascade:place:end | [{ reelIndex, placedSymbols, isInitial, winnerCells }] | New ids are snapped to the grid, before the drop-in. Attach badges here. No :start counterpart. | CascadePlacePhase.ts |
| cascade:dropIn:start | [{ reelIndex }] | The drop-in timeline for this reel began. | CascadeDropInPhase.ts |
| cascade:dropIn:symbol | [{ symbol, view, reelIndex, cellIndex, duration, ease, offsetCells, signal }] | Right before each mover's tween. | CascadeDropInPhase.ts |
| cascade:dropIn:end | [{ reelIndex }] | Every mover is in place; movers get notifyLanded. | CascadeDropInPhase.ts |
| cascade:gravity:start | [{ reelIndex }] | Stage 1 of a 'gravity-then-drop' refill began. Only in that mode. | CascadeDropInPhase.ts (role gravity) |
| cascade:gravity:symbol | [same as dropIn:symbol] | Before each survivor's gravity tween. | CascadeDropInPhase.ts |
| cascade:gravity:end | [{ reelIndex }] | Survivors settled; the gravityHoldMs hold starts after the slowest reel. | CascadeDropInPhase.ts |
| cascade:gravity:error | [{ error }] | A user gate rejected or threw. The engine logs refill-threw and slams. | SpinController.ts refill |
| cascade:chain:start | [{ chain, winners, currentGrid }] | runCascade found winners (chain is 1-based), before destroy. | ReelSet.ts runCascade |
| cascade:chain:end | [{ chain, winners, nextGrid }] | The refill for this stage landed. | ReelSet.ts runCascade |
| cascade:destroy:start | [{ cells }] | destroySymbols() is about to play playDestroy(). Not emitted for an empty list. | ReelSet.ts destroySymbols |
| cascade:destroy:end | [{ cells, failed? }] | All playDestroy() promises settled; failed lists the rejected cells. | ReelSet.ts destroySymbols |
| nudge (3) | |||
| nudge:start | [{ reelIndex, distance, direction: 'forward' | 'reverse' }] | After pre-placement, so the state it shows is the one about to animate. | ReelSet.ts nudge |
| nudge:complete | [{ ...start, symbols }] | The strip is at its new position; symbols is the new visible column. | ReelSet.ts nudge |
| nudge:cancelled | [{ ...start, reason }] | The signal aborted. The strip is snapped to its post-nudge position and the promise rejects with AbortError. nudge:complete does not fire. | ReelSet.ts nudge |
| lifecycle (1) | |||
| destroyed | [] | destroy() ran. | ReelSet.ts destroy |
A few of the groups deserve a sentence of context. Pins are claims on a cell that force a symbol to stay there across spins (sticky wilds, Hold & Win coins). MultiWays sets can change how many cells each reel shows between spins, which is what the shape and adjust events report. Expand adds whole reels one step at a time, the infinity-reels feature. Cascade (also called tumble) is the mode where winning symbols are destroyed and new ones fall in from above, and each such refill is a new round on the bus. Nudge moves one reel by a few cells after it has landed. Each has its own page in this tour.
Per-reel events
The reel bus is small and lower level. Its job is to narrate one column's progress through its phases and to be the original source of the landing events. phase:step is the most detailed thing the library emits: every phase is made of named steps (the stop phase, for example, runs delay, spinOut, land and bounce), and this event reports each one starting, ending, or being cut short by a skip. The same four columns apply.
| Event | Payload | Fires when | Emitted from |
|---|---|---|---|
| phase:enter | [phaseName] | A phase started on this reel. Reel.nudge emits it with the name nudge. | spin/phases/ReelPhase.ts run, core/Reel.ts nudge |
| phase:exit | [phaseName] | The phase ended. | ReelPhase.ts run, Reel.ts nudge |
| phase:step | [{ phase, step, status }] | status is 'start' | 'end' | 'skipped' | 'cut' | 'cancelled'. skipped: a cut step a quicken never started; cut: stopped mid-flight by a quicken; cancelled: stopped by a slam or destroy. | ReelPhase.ts runSteps |
| symbol:created | [symbolId, stripIndex] | A cell took a different symbol (a wrap, a placement, a swap). | Reel.ts _replaceSymbol |
| landing | [symbols] | The per-reel source of spin:reelLanding. | Reel.ts notifyLanded |
| landed | [symbols] | Fully at rest, right before the set's spin:reelLanded. | SpinController.ts _markLanded |
| destroyed | [] | The reel was destroyed. | Reel.ts destroy |
You reach a reel's bus through the set. This is the shape of a listener that only cares about one column, for example a sticky wild tracker that needs to know exactly when reel 2 came to rest:
reelSet.getReel(2).events.on('landed', (symbols) => {
if (symbols.includes('wild')) stickyWilds.push({ reel: 2, ... });
});Hold & Win board events
A Hold & Win board is a grid of cells that each spin on their own, collecting coins across a series of respins. It has a different story to tell than a reel set, so it has its own bus, HoldAndWinBoard.events, typed by HoldAndWinBoardEvents. Every event carries a single object, which makes them easy to log and to forward. Two of them, respin:start and feature:skip, come from the board driver itself; every other one is an effect produced by the pure state machine and replayed onto the bus as a { type, payload } pair. The state machine is explained on the pins and boards page.
feature:enter { seed, respins },feature:skip { inFlight, mode, speed?, payload? },feature:reset { clearedCoins },feature:end { coins, rounds, full }respin:start { round, respinsLeft, spinning },respin:end { round, hits, respinsLeft },respins:changed { value, reason }cell:landed { cell, coin | null }in stagger order,coin:locked { coin, locked, capacity },coin:released { coin, remaining }board:full { coins },cells:activated { cells, capacity },speed:changed { name, previous }(names as strings)
The emitter
All three buses are instances of one small class, EventEmitter, written for this library with no dependencies. It is generic over an event map: a type that pairs each event name with a labelled tuple of argument types, which is where the autocomplete and the typed payloads come from. Inside it keeps a Map from name to listener entries ({ fn, context, once }) and one extra array of wildcard listeners. Every method except emit and listenerCount returns this, so registrations chain.
| Method | Behaviour |
|---|---|
| on(event, fn, context?) | Add a listener. Chainable. |
| once(event, fn, context?) | Add a listener that is removed before its first call. |
| off(event, fn?, context?) | No fn: remove every listener for the event. fn only: remove every entry with that function, whatever its context. Both: remove only the matching pair. |
| onAny(fn(event, ...args)) / offAny(fn) | Wildcard listeners for tracing and recording. They run after the event's own listeners. |
| emit(event, ...args): boolean | Dispatch. Returns false only when there are no specific listeners and no any-listeners. |
| removeAllListeners(event?) | With no argument it also clears the onAny hooks. With an event it leaves them alone. |
| listenerCount(event) | Specific listeners only; any-listeners are not counted. |
The rules below describe what happens during an emit. Most of them you will never notice; the last one you should know about before you ship.
| Rule | What it means for you |
|---|---|
| Listeners are snapshotted before dispatch | Both the listener array and the any-listener array are copied first. A listener that adds or removes another listener during an emit does not change who receives that emit, so you never get a half-updated audience. |
| once() is removed by identity | A once entry is removed before it is called, by entry identity. If you also registered the same function with on(), that persistent registration survives. |
| Listeners get their context | Each listener is called with fn.apply(entry.context, args), so a class method registered with its instance as context keeps its this. |
| onAny runs last | Wildcard listeners run after the event's own listeners and receive the event name as their first argument. Tracing never gets ahead of the real listeners. |
| No error isolation | There is no try/catch in emit. A listener that throws stops the loop: the listeners after it and the any-listeners do not run for that emit, and the error propagates into the engine code that called emit. Wrap a risky listener in your own try/catch. |
A typing caveat, from reading the types rather than from a comment: both event maps extend Record<string, unknown[]>, which adds a string index signature. A misspelled event name therefore probably still type-checks, with unknown[] arguments. Only the declared names get precise argument types. ADR 002 says typos are compile errors; the code is the source of truth here, so lean on autocomplete rather than on the compiler catching a typo.
Watch out
These are the things that catch people. Each is also stated in the table, but they are worth reading together once.
- Count
spin:reelLandingper stage, not per spin. It fires on the animated stop, on a slam, and again on every cascade refill stage, and nothing deduplicates it. - Do not wait for a held reel. Reels you hold with
spin({ holdReels })emit nospin:stoppingand nospin:reelLanded, yet they count as landed and contribute their unchanged cells toSpinResult.symbols. - Do not rely on
skip:boostedto track the speed. It never fires in cascade mode, nor fromslamStop()orrequestSkip(), and the restore at the nextspin()only emitsspeed:changed. Listen tospeed:changedinstead. - Expect
cascade:gravity:*only undermode: 'gravity-then-drop', and never expectcascade:fall:*on arefill(). - Handle
nudge:cancelledandnudge:completeas alternatives: exactly one of them fires. On cancel the strip still lands deterministically. - Clean up your own parallel tweens from the
signalon everycascade:*:symbolpayload. It aborts on a slam, always before the paired:end. - Only expect
pin:migrated,shape:changedandadjust:*on MultiWays sets. - Prefer
off()to a bareremoveAllListeners(). With no argument it also removes theonAnyhooks, which is whatenableDebug().trace()andSpinMetricsrely on.
Where this lives
EventEmitter.tsthe class, 145 lines, no dependenciesReelEvents.tsReelSetEvents, ReelEvents, SpinResult, SkipInfo, RunCascadeResult
core/ReelSet.tsowns_bus; pin, nudge, expand, column, cascade chain eventsspin/SpinController.tsspin, skip, anticipation, adjust events and the landing relayboard/HwTypes.tsHoldAndWinBoardEvents,docs/adr/002-typed-event-emitter.md