Sha256: 934c095ec0ec355e785f87e3a69278131192c7100d6173567eed1b33578a3087
Contents?: true
Size: 1.04 KB
Versions: 15
Compression:
Stored size: 1.04 KB
Contents
JS.Observable=new JS.Module('Observable',{extend:{DEFAULT_METHOD:'update'},addObserver:function(c,b){(this.__observers__=this.__observers__||[]).push({_0:c,_1:b||null})},removeObserver:function(c,b){this.__observers__=this.__observers__||[];b=b||null;var a=this.countObservers();while(a--){if(this.__observers__[a]._0===c&&this.__observers__[a]._1===b){this.__observers__.splice(a,1);return}}},removeObservers:function(){this.__observers__=[]},countObservers:function(){return(this.__observers__=this.__observers__||[]).length},notifyObservers:function(){if(!this.isChanged())return;var c=this.countObservers(),b,a,d;while(c--){b=this.__observers__[c];a=b._0;d=b._1;if(JS.isFn(a))a.apply(d||null,arguments);else a[d||JS.Observable.DEFAULT_METHOD].apply(a,arguments)}},setChanged:function(c){this.__changed__=!(c===false)},isChanged:function(){if(this.__changed__===undefined)this.__changed__=true;return!!this.__changed__}});JS.Observable.include({subscribe:JS.Observable.instanceMethod('addObserver'),unsubscribe:JS.Observable.instanceMethod('removeObserver')},true);
Version data entries
15 entries across 15 versions & 2 rubygems