Skip to content

Commit 3206d3d

Browse files
authored
Save timer transition results (#20)
* Save timer transition results * prettier
1 parent 60af111 commit 3206d3d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/handleEvent.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ export function handleEvent<Context = unknown, Event = unknown>(
254254
eventHandlers = [eventHandlers].filter(Boolean)
255255
}
256256

257+
let timerResult = undefined
258+
257259
if (hasTimerState) {
258260
const timerState = csObject.$timer
259261
const timerEventHandlers: EHArray = []
@@ -268,15 +270,19 @@ export function handleEvent<Context = unknown, Event = unknown>(
268270

269271
// Timers are a special snowflake, if they cause a state transition we have to continue processing normal events.
270272
// Since the handlers don't know what they are processing and to prevent constantly checking for timers, we just run them separately.
271-
doEventHandlers(timerEventHandlers)
273+
timerResult = doEventHandlers(timerEventHandlers)
272274
}
273275

274276
const result = doEventHandlers(eventHandlers)
275277

278+
if (timerResult) {
279+
return timerResult
280+
}
281+
276282
if (result) {
277283
return result
278284
}
279-
285+
280286
return {
281287
state: currentState,
282288
context: newContext,

0 commit comments

Comments
 (0)