summaryrefslogtreecommitdiff
path: root/lib/dojo/Stateful.js
blob: 136b319c74a18736cbe1c7e136142c5564b28a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
	Copyright (c) 2004-2010, 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
*/


if(!dojo._hasResource["dojo.Stateful"]){
dojo._hasResource["dojo.Stateful"]=true;
dojo.provide("dojo.Stateful");
dojo.declare("dojo.Stateful",null,{postscript:function(_1){
if(_1){
dojo.mixin(this,_1);
}
},get:function(_2){
return this[_2];
},set:function(_3,_4){
if(typeof _3==="object"){
for(var x in _3){
this.set(x,_3[x]);
}
return this;
}
var _5=this[_3];
this[_3]=_4;
if(this._watchCallbacks){
this._watchCallbacks(_3,_5,_4);
}
return this;
},watch:function(_6,_7){
var _8=this._watchCallbacks;
if(!_8){
var _9=this;
_8=this._watchCallbacks=function(_a,_b,_c,_d){
var _e=function(_f){
for(var i=0,l=_f&&_f.length;i<l;i++){
try{
_f[i].call(_9,_a,_b,_c);
}
catch(e){
console.error(e);
}
}
};
_e(_8[_a]);
if(!_d){
_e(_8["*"]);
}
};
}
if(!_7&&typeof _6==="function"){
_7=_6;
_6="*";
}
var _10=_8[_6];
if(typeof _10!=="object"){
_10=_8[_6]=[];
}
_10.push(_7);
return {unwatch:function(){
_10.splice(dojo.indexOf(_10,_7),1);
}};
}});
}