---
title: "[ExtJS3.2源码每天一小时]（之九）补充：示例"
author: "ting570732"
date: "2010-09-19T14:46:08Z"
tags: ["Java"]
categories: ["Web前端"]
slug: "extjs3-2"
draft: false
lastmod: "2010-09-19T14:59:03Z"
id: 767270
url: "https://liust1987.iteye.com/blog/767270"
---

<span style="color:red">拦截器示例：</span>


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

```


<span style="color:red">创建回调简单示例1：</span>

```java

var testFunc = function(a){
	alert('executing...'+a);
}
//创建一个回调函数
var callFunc = testFunc.createCallback('adsadfsf');

callFunc();//打出 executing...adsadfsf

```


<span style="color:red">创建回调简单示例2 （与1的区别 另有博文说明）：</span>

```java

var testFunc = function(a){
    alert('executing...'+a);
}
//创建一个回调函数 
var callFunc = testFunc.createDelegete(window,['adsadfsf']);
callFunc();//打出 executing...adsadfsf

```


<span style="color:red">创建一个顺序执行的函数：</span>

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

```



<span style="color:red">创建一个延迟执行的函数：</span>

```java

var testFunc = function(a){
	alert('executing...'+a);
}
//window指作用域 ['haha']传入参数数组
testFunc.defer(2000,window,['haha'],true);//打出 executing...haha 

```