JavaScript: pubsub