Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(async-pipe): include observable example #8900

Merged
merged 1 commit into from Jun 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions modules/@angular/common/src/pipes/async_pipe.ts
Expand Up @@ -36,22 +36,29 @@ var _observableStrategy = new ObservableStrategy();
var __unused: Promise<any>; // avoid unused import when Promise union types are erased

/**
* The `async` pipe subscribes to an Observable or Promise and returns the latest value it has
* The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
* emitted.
* When a new value is emitted, the `async` pipe marks the component to be checked for changes.
* When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
* potential memory leaks.
*
* ### Example
* ## Usage
*
* object | async
*
* where `object` is of type `Observable` or of type `Promise`.
*
* ## Examples
*
* This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
* promise.
*
* {@example core/pipes/ts/async_pipe/async_pipe_example.ts region='AsyncPipe'}
* {@example core/pipes/ts/async_pipe/async_pipe_example.ts region='AsyncPipePromise'}
*
* It's also possible to use `async` with Observables. The example below binds the `time` Observable
* to the view. Every 500ms, the `time` Observable updates the view with the current time.
*
* ```typescript
* ```
* {@example core/pipes/ts/async_pipe/async_pipe_example.ts region='AsyncPipeObservable'}
*/
@Pipe({name: 'async', pure: false})
@Injectable()
Expand Down
Expand Up @@ -2,7 +2,7 @@ import {Component, provide} from '@angular/core';
import {bootstrap} from '@angular/platform-browser';
import {Observable, Subscriber} from 'rxjs/Rx';

// #docregion AsyncPipe
// #docregion AsyncPipePromise
@Component({
selector: 'async-example',
template: `<div>
Expand Down