Simple pub/sub implementation with javascript