4 ms·
> but the alternative implementation of state machines in any frontend framework would look terrible async function animation(setState, signal) { while (
by SebastianKra 2y ago
> 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()
}
}
}
- weatherlight 2y agoI love FP. but this is way more readable than the above. It doesn't fight the ergonomics of javascript.