Skip to content

Commit 2ab8c59

Browse files
committed
docs(pipes): improve docs for async pipe
Closes angular#4104
1 parent 0653b82 commit 2ab8c59

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

modules/angular2/src/core/pipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @module
33
* @description
4-
* This module provides advanced support for extending change detection.
4+
* This module provides a set of common Pipes.
55
*/
66

77
export {AsyncPipe} from './pipes/async_pipe';

modules/angular2/src/core/pipes/async_pipe.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,27 @@ var _observableStrategy = new ObservableStrategy();
3636

3737

3838
/**
39-
* Implements async bindings to Observable and Promise.
39+
* The `async` pipe subscribes to an Observable or Promise and returns the latest value it has
40+
* emitted.
41+
* When a new value is emitted, the `async` pipe marks the component to be checked for changes.
4042
*
4143
* # Example
44+
* The example below binds the `time` Observable to the view. Every 500ms, the `time` Observable
45+
* updates the view with the current time.
4246
*
43-
* In this example we bind the description observable to the DOM. The async pipe will convert an
44-
*observable to the
45-
* latest value it emitted. It will also request a change detection check when a new value is
46-
*emitted.
47-
*
48-
* ```
47+
* import {Observable} from 'angular2/core';
4948
* @Component({
50-
* selector: "task-cmp",
51-
* changeDetection: ChangeDetectionStrategy.OnPush
49+
* selector: "task-cmp"
5250
* })
5351
* @View({
54-
* template: "Task Description {{ description | async }}"
52+
* template: "Time: {{ time | async }}"
5553
* })
5654
* class Task {
57-
* description:Observable<string>;
55+
* time = new Observable<number>(observer => {
56+
* setInterval(_ =>
57+
* observer.next(new Date().getTime(), 500);
58+
* });
5859
* }
59-
*
60-
* ```
6160
*/
6261
@Pipe({name: 'async', pure: false})
6362
@Injectable()

0 commit comments

Comments
 (0)