Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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()
      }
    }
  }


I love FP. but this is way more readable than the above. It doesn't fight the ergonomics of javascript.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: