Publish & subscribe Javascript Library Pattern