add javascript observer design pattern