Rewrite of my old pubsub gist to make it available as an AMD module