日期:2014-05-16  浏览次数:20303 次

[ExtJS3.2源码每天一小时](之九)补充:示例
拦截器示例:

var testFunc = function(a){
	alert('executing...'+a);
}
var func = testFunc.createInterceptor(
   function(){alert('intercepted');}
);
testFunc();//拦截器不会生效
func();//拦截器生效,所以必须使用createInterceptor返回的新函数去执行才能实现拦截,这与extjs的内部实现是吻合的



创建回调简单示例1:
var testFunc = function(a){
	alert('executing...'+a);
}
//创建一个回调函数
var callFunc = testFunc.createCallback('adsadfsf');

callFunc();//打出 executing...adsadfsf


创建回调简单示例2 (与1的区别 另有博文说明):
var testFunc = function(a){
    alert('executing...'+a);
}
//创建一个回调函数 
var callFunc = testFunc.createDelegete(window,['adsadfsf']);
callFunc();//打出 executing...adsadfsf


创建一个顺序执行的函数:
var testFunc = function(a){
    alert('executing...'+a);
}
//创建一个回调函数
var callFunc = testFunc.createSequence(funciton(a){
    alert('executing...2'+a);
});
callFunc();//打出 executing...adsadfsf 后接着打出 executing2...adsadfsf 



创建一个延迟执行的函数:
var testFunc = function(a){
	alert('executing...'+a);
}
//window指作用域 ['haha']传入参数数组
testFunc.defer(2000,window,['haha'],true);//打出 executing...haha