Another implementation of mediator pattern in JavaScript