1
|
/**
|
2
|
* @license
|
3
|
* Copyright Google Inc. All Rights Reserved.
|
4
|
*
|
5
|
* Use of this source code is governed by an MIT-style license that can be
|
6
|
* found in the LICENSE file at https://angular.io/license
|
7
|
*/
|
8
|
import { ChangeDetectorRef, OnDestroy, PipeTransform } from '@angular/core';
|
9
|
import { Observable } from 'rxjs/Observable';
|
10
|
/**
|
11
|
* @ngModule CommonModule
|
12
|
* @whatItDoes Unwraps a value from an asynchronous primitive.
|
13
|
* @howToUse `observable_or_promise_expression | async`
|
14
|
* @description
|
15
|
* The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
|
16
|
* emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
|
17
|
* changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
|
18
|
* potential memory leaks.
|
19
|
*
|
20
|
*
|
21
|
* ## Examples
|
22
|
*
|
23
|
* This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
|
24
|
* promise.
|
25
|
*
|
26
|
* {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
|
27
|
*
|
28
|
* It's also possible to use `async` with Observables. The example below binds the `time` Observable
|
29
|
* to the view. The Observable continuously updates the view with the current time.
|
30
|
*
|
31
|
* {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
|
32
|
*
|
33
|
* @stable
|
34
|
*/
|
35
|
export declare class AsyncPipe implements OnDestroy, PipeTransform {
|
36
|
private _ref;
|
37
|
private _latestValue;
|
38
|
private _latestReturnedValue;
|
39
|
private _subscription;
|
40
|
private _obj;
|
41
|
private _strategy;
|
42
|
constructor(_ref: ChangeDetectorRef);
|
43
|
ngOnDestroy(): void;
|
44
|
transform<T>(obj: null): null;
|
45
|
transform<T>(obj: undefined): undefined;
|
46
|
transform<T>(obj: Observable<T>): T | null;
|
47
|
transform<T>(obj: Promise<T>): T | null;
|
48
|
private _subscribe(obj);
|
49
|
private _selectStrategy(obj);
|
50
|
private _dispose();
|
51
|
private _updateLatestValue(async, value);
|
52
|
}
|