publish-subscribe pattern code bricks for JavaScript