JavaScript: Pub/Sub Mediator Pattern