A simple implementation of the mediator pattern for Javascript asynchronous events