Skip to content

Instantly share code, notes, and snippets.

Ronny Hanssen Spiralis

View GitHub Profile
Spiralis / XState Handball Match Machine.js
Last active Apr 10, 2019
A simplified XState statecharts state-machine for running a handball game. Typically used with a control app for the match officials. Note: There are still parts missing in this sample, like disciplinary actions (2 min, yellow and red cards), as well as who made the goals, and adjusting the match-clock (adjusting the data on the fly). But, it is…
View XState Handball Match Machine.js
// Available variables:
// Machine (machine factory function)
// XState (all XState exports)
function pad(n, width) {
var n = n + "";
return n.length >= width ? n : new Array(width - n.length + 1).join("0") + n;
function displayTime(ticksInSecs) {
You can’t perform that action at this time.