Three ways of handling user input (2022)

# · ✸ 66 · 💬 21 · 18 days ago · dubroy.com · stcucufa · 📷
It's 2022 and things are pretty much the same: the dominant way of handling user input is still based on events and - in some form or another - callbacks. In nearly every code base I've worked in, the hairiest, most difficult-to-modify logic is in the event handling code. You can "Jump into" control at many parts of the code, and the order of the handlers is purely determined by the order that the events arrive. On the plus side, the control flow is more explicit when compared to the event listener approach. With events, there's an inversion of control: the event dispatch mechanism determines when each component observes the state change. You could have a single callback that handles all the events, rather than a separate callback for each event. The first line of the loop blocks on a pointerdown event; the other handlers aren't even active until control proceeds past that point.
Three ways of handling user input (2022)



Send Feedback | WebAssembly Version (beta)