Skip to content

Commit 9422abb

Browse files
author
Zhicheng WANG
committed
119c01c cf7bfdbbfe feat: 添加 rxjs 中文文档链接
1 parent 119c01c commit 9422abb

File tree

85 files changed

+31
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+31
-31
lines changed

generated/docs/api/core/testing/c_omponentf_ixture.json

+1-1
Large diffs are not rendered by default.

generated/docs/api/router/r_oute.json

+1-1
Large diffs are not rendered by default.

generated/docs/api/service-worker/s_wu_pdate.json

+1-1
Large diffs are not rendered by default.

generated/docs/app/search-data.json

+1-1
Large diffs are not rendered by default.

generated/docs/guide/comparing-observables.json

+1-1
Large diffs are not rendered by default.

generated/docs/guide/glossary.json

+1-1
Large diffs are not rendered by default.

generated/docs/guide/observables-in-angular.json

+1-1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"id": "guide/practical-observable-usage",
33
"title": "Practical observable usage",
4-
"contents": "\n\n\n<div class=\"github-links\">\n <a href=\"https://github.com/angular/angular-cn/edit/aio/aio/content/guide/practical-observable-usage.md?message=docs%3A%20请简述你的修改...\" aria-label=\"提供编辑建议\" title=\"提供编辑建议\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n</div>\n\n\n<div class=\"content\">\n <h1 id=\"practical-observable-usage\" translation-result=\"on\">可观察对象用法实战<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#practical-observable-usage\"><i class=\"material-icons\">link</i></a></h1><h1 translation-origin=\"off\" id=\"practical-observable-usage\">Practical observable usage<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#practical-observable-usage\"><i class=\"material-icons\">link</i></a></h1>\n\n<p translation-result=\"on\">这里示范了一些在某种领域中可观察对象会特别有用的例子。</p><p translation-origin=\"off\">Here are some examples of domains in which observables are particularly useful.</p>\n\n<h2 id=\"type-ahead-suggestions\" translation-result=\"on\">输入提示(type-ahead)建议<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#type-ahead-suggestions\"><i class=\"material-icons\">link</i></a></h2><h2 translation-origin=\"off\" id=\"type-ahead-suggestions\">Type-ahead suggestions<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#type-ahead-suggestions\"><i class=\"material-icons\">link</i></a></h2>\n\n<p translation-result=\"on\">可观察对象可以简化输入提示建议的实现方式。典型的输入提示要完成一系列独立的任务:</p><p translation-origin=\"off\">Observables can simplify the implementation of type-ahead suggestions.\nTypically, a type-ahead has to do a series of separate tasks:</p>\n\n<ul>\n<li>\n<p translation-result=\"on\">从输入中监听数据</p><p translation-origin=\"off\">Listen for data from an input</p>\n\n</li>\n<li>\n<p translation-result=\"on\">移除输入值前后的空白字符,并确认它达到了最小长度</p><p translation-origin=\"off\">Trim the value (remove whitespace) and make sure it's a minimum length</p>\n\n</li>\n<li>\n<p translation-result=\"on\">防抖(这样才能防止连续按键时每次按键都发起 API 请求,而应该等到按键出现停顿时才发起)</p><p translation-origin=\"off\">Debounce (so as not to send off API requests for every keystroke, but instead wait for a break in keystrokes)</p>\n\n</li>\n<li>\n<p translation-result=\"on\">如果输入值没有变化,则不要发起请求(比如按某个字符,然后快速按退格)</p><p translation-origin=\"off\">Don't send a request if the value stays the same (rapidly hit a character, then backspace, for instance)</p>\n\n</li>\n<li>\n<p translation-result=\"on\">如果已发出的 AJAX 请求的结果会因为后续的修改而变得无效,那就取消它</p><p translation-origin=\"off\">Cancel ongoing AJAX requests if their results will be invalidated by the updated results</p>\n\n</li>\n</ul>\n<p translation-result=\"on\">完全用 JavaScript 的传统写法实现这个功能可能需要大量的工作。使用可观察对象,你可以使用这样一个 RxJS 操作符的简单序列:</p><p translation-origin=\"off\">Writing this in full JavaScript can be quite involved.\nWith observables, you can use a simple series of RxJS operators:</p>\n\n<code-example header=\"Typeahead\" path=\"practical-observable-usage/src/typeahead.ts\">\nimport { fromEvent, Observable } from 'rxjs';\nimport { ajax } from 'rxjs/ajax';\nimport { debounceTime, distinctUntilChanged, filter, map, switchMap } from 'rxjs/operators';\n\nconst searchBox = document.getElementById('search-box') as HTMLInputElement;\n\nconst typeahead = fromEvent(searchBox, 'input').pipe(\n map(e => (e.target as HTMLInputElement).value),\n filter(text => text.length > 2),\n debounceTime(10),\n distinctUntilChanged(),\n switchMap(searchTerm => ajax(`/api/endpoint?search=${searchTerm}`))\n);\n\ntypeahead.subscribe(data => {\n // Handle the data from the API\n});\n\n\n</code-example>\n<h2 id=\"exponential-backoff\" translation-result=\"on\">指数化退避<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#exponential-backoff\"><i class=\"material-icons\">link</i></a></h2><h2 translation-origin=\"off\" id=\"exponential-backoff\">Exponential backoff<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#exponential-backoff\"><i class=\"material-icons\">link</i></a></h2>\n\n<p translation-result=\"on\">指数化退避是一种失败后重试 API 的技巧,它会在每次连续的失败之后让重试时间逐渐变长,超过最大重试次数之后就会彻底放弃。如果使用承诺和其它跟踪 AJAX 调用的方法会非常复杂,而使用可观察对象,这非常简单:</p><p translation-origin=\"off\">Exponential backoff is a technique in which you retry an API after failure, making the time in between retries longer after each consecutive failure, with a maximum number of retries after which the request is considered to have failed.\nThis can be quite complex to implement with promises and other methods of tracking AJAX calls.\nWith observables, it is very easy:</p>\n\n<code-example header=\"Exponential backoff\" path=\"practical-observable-usage/src/backoff.ts\">\nimport { of, pipe, range, throwError, timer, zip } from 'rxjs';\nimport { ajax } from 'rxjs/ajax';\nimport { map, mergeMap, retryWhen } from 'rxjs/operators';\n\nexport function backoff(maxTries: number, delay: number) {\n return pipe(\n retryWhen(attempts =>\n zip(range(1, maxTries + 1), attempts).pipe(\n mergeMap(([i, err]) => (i > maxTries) ? throwError(err) : of(i)),\n map(i => i * i),\n mergeMap(v => timer(v * delay)),\n ),\n ),\n );\n}\n\najax('/api/endpoint')\n .pipe(backoff(3, 250))\n .subscribe(function handleData(data) { /* ... */ });\n\n</code-example>\n<!-- links -->\n<!-- external links -->\n<!-- end links -->\n\n <div class=\"reviewed\">最后复查时间: 2/28/2022</div>\n</div>\n\n\n<!-- links to this doc:\n-->\n<!-- links from this doc:\n - guide/practical-observable-usage#exponential-backoff\n - guide/practical-observable-usage#practical-observable-usage\n - guide/practical-observable-usage#type-ahead-suggestions\n - https://github.com/angular/angular-cn/edit/aio/aio/content/guide/practical-observable-usage.md?message=docs%3A%20请简述你的修改...\n-->"
4+
"contents": "\n\n\n<div class=\"github-links\">\n <a href=\"https://github.com/angular/angular-cn/edit/aio/aio/content/guide/practical-observable-usage.md?message=docs%3A%20请简述你的修改...\" aria-label=\"提供编辑建议\" title=\"提供编辑建议\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n</div>\n\n\n<div class=\"content\">\n <h1 id=\"practical-observable-usage\" translation-result=\"on\">可观察对象用法实战<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#practical-observable-usage\"><i class=\"material-icons\">link</i></a></h1><h1 translation-origin=\"off\" id=\"practical-observable-usage\">Practical observable usage<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#practical-observable-usage\"><i class=\"material-icons\">link</i></a></h1>\n\n<p translation-result=\"on\">这里示范了一些在某种领域中可观察对象会特别有用的例子。</p><p translation-origin=\"off\">Here are some examples of domains in which observables are particularly useful.</p>\n\n<h2 id=\"type-ahead-suggestions\" translation-result=\"on\">输入提示(type-ahead)建议<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#type-ahead-suggestions\"><i class=\"material-icons\">link</i></a></h2><h2 translation-origin=\"off\" id=\"type-ahead-suggestions\">Type-ahead suggestions<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#type-ahead-suggestions\"><i class=\"material-icons\">link</i></a></h2>\n\n<p translation-result=\"on\">可观察对象可以简化输入提示建议的实现方式。典型的输入提示要完成一系列独立的任务:</p><p translation-origin=\"off\">Observables can simplify the implementation of type-ahead suggestions.\nTypically, a type-ahead has to do a series of separate tasks:</p>\n\n<ul>\n<li>\n<p translation-result=\"on\">从输入中监听数据</p><p translation-origin=\"off\">Listen for data from an input</p>\n\n</li>\n<li>\n<p translation-result=\"on\">移除输入值前后的空白字符,并确认它达到了最小长度</p><p translation-origin=\"off\">Trim the value (remove whitespace) and make sure it's a minimum length</p>\n\n</li>\n<li>\n<p translation-result=\"on\">防抖(这样才能防止连续按键时每次按键都发起 API 请求,而应该等到按键出现停顿时才发起)</p><p translation-origin=\"off\">Debounce (so as not to send off API requests for every keystroke, but instead wait for a break in keystrokes)</p>\n\n</li>\n<li>\n<p translation-result=\"on\">如果输入值没有变化,则不要发起请求(比如按某个字符,然后快速按退格)</p><p translation-origin=\"off\">Don't send a request if the value stays the same (rapidly hit a character, then backspace, for instance)</p>\n\n</li>\n<li>\n<p translation-result=\"on\">如果已发出的 AJAX 请求的结果会因为后续的修改而变得无效,那就取消它</p><p translation-origin=\"off\">Cancel ongoing AJAX requests if their results will be invalidated by the updated results</p>\n\n</li>\n</ul>\n<p translation-result=\"on\">完全用 JavaScript 的传统写法实现这个功能可能需要大量的工作。使用可观察对象,你可以使用这样一个 RxJS 操作符的简单序列:</p><p translation-origin=\"off\">Writing this in full JavaScript can be quite involved.\nWith observables, you can use a simple series of RxJS operators:</p>\n\n<code-example header=\"Typeahead\" path=\"practical-observable-usage/src/typeahead.ts\">\nimport { fromEvent, Observable } from 'rxjs';\nimport { ajax } from 'rxjs/ajax';\nimport { debounceTime, distinctUntilChanged, filter, map, switchMap } from 'rxjs/operators';\n\nconst searchBox = document.getElementById('search-box') as HTMLInputElement;\n\nconst typeahead = fromEvent(searchBox, 'input').pipe(\n map(e => (e.target as HTMLInputElement).value),\n filter(text => text.length > 2),\n debounceTime(10),\n distinctUntilChanged(),\n switchMap(searchTerm => ajax(`/api/endpoint?search=${searchTerm}`))\n);\n\ntypeahead.subscribe(data => {\n // Handle the data from the API\n});\n\n\n</code-example>\n<h2 id=\"exponential-backoff\" translation-result=\"on\">指数化退避<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#exponential-backoff\"><i class=\"material-icons\">link</i></a></h2><h2 translation-origin=\"off\" id=\"exponential-backoff\">Exponential backoff<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/practical-observable-usage#exponential-backoff\"><i class=\"material-icons\">link</i></a></h2>\n\n<p translation-result=\"on\">指数化退避是一种失败后重试 API 的技巧,它会在每次连续的失败之后让重试时间逐渐变长,超过最大重试次数之后就会彻底放弃。如果使用 Promise 对象和其它跟踪 AJAX 调用的方法会非常复杂,而使用可观察对象,这非常简单:</p><p translation-origin=\"off\">Exponential backoff is a technique in which you retry an API after failure, making the time in between retries longer after each consecutive failure, with a maximum number of retries after which the request is considered to have failed.\nThis can be quite complex to implement with promises and other methods of tracking AJAX calls.\nWith observables, it is very easy:</p>\n\n<code-example header=\"Exponential backoff\" path=\"practical-observable-usage/src/backoff.ts\">\nimport { of, pipe, range, throwError, timer, zip } from 'rxjs';\nimport { ajax } from 'rxjs/ajax';\nimport { map, mergeMap, retryWhen } from 'rxjs/operators';\n\nexport function backoff(maxTries: number, delay: number) {\n return pipe(\n retryWhen(attempts =>\n zip(range(1, maxTries + 1), attempts).pipe(\n mergeMap(([i, err]) => (i > maxTries) ? throwError(err) : of(i)),\n map(i => i * i),\n mergeMap(v => timer(v * delay)),\n ),\n ),\n );\n}\n\najax('/api/endpoint')\n .pipe(backoff(3, 250))\n .subscribe(function handleData(data) { /* ... */ });\n\n</code-example>\n<!-- links -->\n<!-- external links -->\n<!-- end links -->\n\n <div class=\"reviewed\">最后复查时间: 2/28/2022</div>\n</div>\n\n\n<!-- links to this doc:\n-->\n<!-- links from this doc:\n - guide/practical-observable-usage#exponential-backoff\n - guide/practical-observable-usage#practical-observable-usage\n - guide/practical-observable-usage#type-ahead-suggestions\n - https://github.com/angular/angular-cn/edit/aio/aio/content/guide/practical-observable-usage.md?message=docs%3A%20请简述你的修改...\n-->"
55
}

generated/docs/guide/rx-library.json

+1-1
Large diffs are not rendered by default.

generated/docs/guide/service-worker-intro.json

+1-1
Large diffs are not rendered by default.

generated/docs/guide/testing-components-scenarios.json

+1-1
Large diffs are not rendered by default.

generated/docs/guide/testing-utility-apis.json

+1-1
Large diffs are not rendered by default.

generated/docs/guide/upgrade.json

+1-1
Large diffs are not rendered by default.

generated/navigation.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2119,12 +2119,12 @@
21192119
"prerelease": [
21202120
"local"
21212121
],
2122-
"build": "sha.cf7bfdbbfe",
2122+
"build": "sha.207aa2228d",
21232123
"version": "14.1.0-local",
21242124
"codeName": "snapshot",
21252125
"isSnapshot": true,
2126-
"full": "14.1.0-local+sha.cf7bfdbbfe",
2126+
"full": "14.1.0-local+sha.207aa2228d",
21272127
"branch": "master",
2128-
"commitSHA": "cf7bfdbbfe7895aac3e6afb6f4bf90f7129fcb0c"
2128+
"commitSHA": "207aa2228dde490b580543d8c7c8822784c0783b"
21292129
}
21302130
}
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

generated/zips/elements/elements.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

generated/zips/forms/forms.zip

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

generated/zips/http/http.zip

0 Bytes
Binary file not shown.

generated/zips/http/specs.http.zip

0 Bytes
Binary file not shown.

generated/zips/i18n/i18n.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

generated/zips/pipes/pipes.zip

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

generated/zips/router/router.zip

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

generated/zips/security/security.zip

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

generated/zips/testing/testing.zip

0 Bytes
Binary file not shown.

generated/zips/toh-pt0/toh-pt0.zip

0 Bytes
Binary file not shown.

generated/zips/toh-pt1/toh-pt1.zip

0 Bytes
Binary file not shown.

generated/zips/toh-pt2/toh-pt2.zip

0 Bytes
Binary file not shown.

generated/zips/toh-pt3/toh-pt3.zip

0 Bytes
Binary file not shown.

generated/zips/toh-pt4/toh-pt4.zip

0 Bytes
Binary file not shown.

generated/zips/toh-pt5/toh-pt5.zip

0 Bytes
Binary file not shown.

generated/zips/toh-pt6/toh-pt6.zip

0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)