forked from pandoraui/jquery-chm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeferred.pipe.html
86 lines (82 loc) · 3.89 KB
/
deferred.pipe.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>deferred.pipe([doneFilter],[failFilter],[progressFilter] ) | jQuery API 中文手册</title>
<meta name="author" content="jQuery 中文手册 - hemin.cn/jq/">
<meta name="description" content="jQuery中文手册(在线版),作者:hemin,在线手册:hemin.cn/jq/,下载:hemin.cn/jq/downloads/">
<link type="text/css" rel="stylesheet" href="style/style.css" tppabs="http://hemin.cn/jq/style/style.css" />
<script type="text/javascript" src="js/jquery.min.js" tppabs="http://hemin.cn/jq/js/jquery.min.js"></script>
<script type="text/javascript" src="js/js.js" tppabs="http://hemin.cn/jq/js/js.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-15318881-10', 'pandoraui.github.io');
ga('send', 'pageview');
</script>
</head>
<body id="split">
<div id="content" class="a2">
<div rel="deferred.pipe">
<h2><span>返回值:Deferred Object</span>deferred.pipe([doneFilter],[failFilter],[progressFilter])</h2>
<h3>概述</h3>
<div class="desc">
<p>筛选器和/或链Deferreds的实用程序方法。</p>
<div class="longdesc">
<p>deferred.pipe()方法返回一个新的promise,该过滤器通过一个函数有关的递延状态和价值。该doneFilter和failFilter原递延过滤功能的解决/拒绝的状态和价值。这些过滤器函数可以返回一个新的值被传递给管道承诺的done()或fail()的回调,或者他们可以返回另一个观察对象(推迟,承诺等),将通过它的解决/拒绝状态和价值,以保证管道的回调。如果使用的是过滤功能null ,或不指定,则管道的承诺将得到解决或原驳回值具有相同。</p>
<p class="outmoded">注意:从 jQuery 1.8 开始,deferred.pipe() 方法过时. 应该使用deferred.then() 代替它。</p>
</div>
</div>
<h3>参数</h3>
<div class="parameter">
<h4><strong>doneFilter,failFilter</strong><em>V1.6</em></h4>
<p><strong>doneFilter</strong>:可选函数,当递延得到解决时调用。</p>
<p><strong>failFilter</strong>:可选函数,当递延得被拒绝时调用。 </p>
<h4><strong>doneFilter,failFilter,progressFilter</strong><em>V1.7</em></h4>
<p><strong>doneFilter</strong>:可选函数,当递延得到解决时调用。</p>
<p><strong>failFilter</strong>:可选函数,当递延得被拒绝时调用。 </p>
<p><strong>progressFilter</strong>:一个可选的函数会在延迟调用被拒绝时被调用</p>
</div>
<div class="example">
<h3>示例</h3>
<span id="f_ad2"></span>
<h4>描述:</h4>
<p>过滤解决值:</p>
<h5>jQuery 代码:</h5>
<pre><code>var defer = $.Deferred(),
filtered = defer.pipe(function( value ) {
return value * 2;
});
defer.resolve( 5 );
filtered.done(function( value ) {
alert( "Value is ( 2*5 = ) 10: " + value );
});</code></pre>
<h4>描述:</h4>
<p>过滤器拒值:</p>
<h5>jQuery 代码:</h5>
<pre><code>var defer = $.Deferred(),
filtered = defer.pipe( null, function( value ) {
return value * 3;
});
defer.reject( 6 );
filtered.fail(function( value ) {
alert( "Value is ( 3*6 = ) 18: " + value );
});;</code></pre>
<h4>描述:</h4>
<p>链任务:</p>
<h5>jQuery 代码:</h5>
<pre><code>var request = $.ajax( url, { dataType: "json" } ),
chained = request.pipe(function( data ) {
return $.ajax( url2, { data: { user: data.userId } } );
});
chained.done(function( data ) {
// data retrieved from url2 as provided by the first request
});
</code></pre>
</div>
</div>
</div>
</body>
</html>