Chained and interruptable events in Javascript