What is an expressive way of looking for patterns of events over time, and triggering new events?
For example, user interface events are often built up patterns of simpler events, such as mousedown/up, mousemove, or keyup/keydown.
A drag and drop interaction requires listening for a mousedown event, followed by a number of mousemove events, followed by a mouseup, and looking for if draggable/droppable UI objects are targeted by the different events. Additionally, you might want to have a timing and distance threshold to avoid triggering a drag when the user might have tried to click, and you might want to look for modifier keys, or escape to cancel the interaction.
Dealing with these things as number of individual event listeners quickly gets complex and error prone, tricky to debug, and often leads to conflicts between different events.
What abstractions are common for expressing these patterns succinctly and clearly?
Aucun commentaire:
Enregistrer un commentaire