simple publish subscribe pattern in javascript