> but the alternative implementation of state machines in any frontend framework would look terrible
async function animation(setState, signal) {
while (true) {
setState("a", 1)
setState("b", "")
await wait(250)
signal.throwIfAborted()
for (_ of range(0, 3)) {
setState("a", (_) => _ * 2)
await wait(250)
signal.throwIfAborted()
setState("b", (_) => _ + ".")
await wait(250)
signal.throwIfAborted()
}
}
}