Chained and interruptible events in Javascript