Simple Pub Sub implementation in javascript