/* Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ //>>built define("dojo/store/Observable",["../_base/kernel","../_base/lang","../_base/Deferred","../_base/array"],function(_1,_2,_3,_4){ var ds=_2.getObject("dojo.store",true); return ds.Observable=function(_5){ var _6,_7=[],_8=0; _5.notify=function(_9,_a){ _8++; var _b=_7.slice(); for(var i=0,l=_b.length;i-1?_1c:_19.length; _19.splice(_1f,0,_17); _1d=_4.indexOf(_11(_19),_17); _19.splice(_1f,1); if((_e.start&&_1d==0)||(!_1a&&_1d==_19.length)){ _1d=-1; }else{ _19.splice(_1d,0,_17); } } }else{ if(_17&&!_e.start){ _1d=_1c>=0?_1c:(_5.defaultIndex||0); } } if((_1c>-1||_1d>-1)&&(_16||!_11||(_1c!=_1d))){ var _20=_13.slice(); for(i=0;_15=_20[i];i++){ _15(_17||_1b,_1c,_1d); } } }); }); } return {cancel:function(){ var _21=_4.indexOf(_13,_15); if(_21>-1){ _13.splice(_21,1); if(!_13.length){ _7.splice(_4.indexOf(_7,_14),1); } } }}; }; } return _f; }; var _22; function _23(_24,_25){ var _26=_5[_24]; if(_26){ _5[_24]=function(_27){ if(_22){ return _26.apply(this,arguments); } _22=true; try{ var _28=_26.apply(this,arguments); _3.when(_28,function(_29){ _25((typeof _29=="object"&&_29)||_27); }); return _28; } finally{ _22=false; } }; } }; _23("put",function(_2a){ _5.notify(_2a,_5.getIdentity(_2a)); }); _23("add",function(_2b){ _5.notify(_2b); }); _23("remove",function(id){ _5.notify(undefined,id); }); return _5; }; });