Simple mediator pattern written in JS