Observable.js
资源名称:WorkFlow.rar [点击查看]
上传用户:ahit0551
上传日期:2009-04-15
资源大小:2345k
文件大小:1k
源码类别:
xml/soap/webservice
开发平台:
Java
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) xio.name 2006</p>
- * @author xio
- */ function Observable() { this.observers = new Array(); } Observable.prototype.addObserver = function (observer) { if (this.observers.indexOf(observer) < 0) { this.observers.add(observer); } }; Observable.prototype.countObservers = function () { return this.observers.size(); }; Observable.prototype.removeObserver = function (observer) { this.observers.remove(observer); }; Observable.prototype.removeObservers = function () { this.observers.clear(); }; Observable.prototype.notifyObservers = function (arg) { for (var i = 0; i < this.observers.size(); i++) { this.observers.get(i).update(this, arg); } };