refactor(ChangeDetection): rename AsyncPipe to ObservablePipe

The async pipe in templates will now delegate to both Observable pipe or Promise pipe,
whichever first says it can support the input. Therefore, it's beneficial to disambiguate
the name of the AsyncPipe/AsyncPipeFactory constructors to reflect that these actually
support only Observables.
This commit is contained in:
Jeff Cross 2015-05-11 14:25:27 -07:00
parent 7498758584
commit 5691063ba0
3 changed files with 11 additions and 9 deletions

View File

@ -3,7 +3,8 @@ import {PipeFactory} from './pipes/pipe';
import {PipeRegistry} from './pipes/pipe_registry';
import {IterableChangesFactory} from './pipes/iterable_changes';
import {KeyValueChangesFactory} from './pipes/keyvalue_changes';
import {AsyncPipeFactory} from './pipes/async_pipe';
import {ObservablePipeFactory} from './pipes/observable_pipe';
import {PromisePipeFactory} from './pipes/promise_pipe';
import {NullPipeFactory} from './pipes/null_pipe';
import {BindingRecord} from './binding_record';
import {DirectiveRecord} from './directive_record';
@ -37,7 +38,8 @@ export var iterableDiff: List <
*
* @exportedAs angular2/pipes
*/
export var async: List < PipeFactory >= [new AsyncPipeFactory(), new NullPipeFactory()];
export var async: List <
PipeFactory >= [new ObservablePipeFactory(), new PromisePipeFactory(), new NullPipeFactory()];
export var defaultPipes = {
"iterableDiff": iterableDiff,

View File

@ -35,7 +35,7 @@ export var __esModule = true;
*
* @exportedAs angular2/pipes
*/
export class AsyncPipe extends Pipe {
export class ObservablePipe extends Pipe {
_ref: ChangeDetectorRef;
_latestValue: Object;
@ -101,15 +101,15 @@ export class AsyncPipe extends Pipe {
}
/**
* Provides a factory for [AsyncPipe].
* Provides a factory for [ObervablePipe].
*
* @exportedAs angular2/pipes
*/
@CONST()
export class AsyncPipeFactory extends PipeFactory {
export class ObservablePipeFactory extends PipeFactory {
constructor() { super(); }
supports(obs): boolean { return ObservableWrapper.isObservable(obs); }
create(cdRef): Pipe { return new AsyncPipe(cdRef); }
create(cdRef): Pipe { return new ObservablePipe(cdRef); }
}

View File

@ -3,12 +3,12 @@ import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach,
import {IMPLEMENTS} from 'angular2/src/facade/lang';
import {WrappedValue} from 'angular2/src/change_detection/pipes/pipe';
import {AsyncPipe} from 'angular2/src/change_detection/pipes/async_pipe';
import {ObservablePipe} from 'angular2/src/change_detection/pipes/observable_pipe';
import {ChangeDetectorRef} from 'angular2/src/change_detection/change_detector_ref';
import {EventEmitter, Observable, ObservableWrapper, PromiseWrapper} from 'angular2/src/facade/async';
export function main() {
describe("AsyncPipe", () => {
describe("ObservablePipe", () => {
var emitter;
var pipe;
var ref;
@ -17,7 +17,7 @@ export function main() {
beforeEach(() => {
emitter = new EventEmitter();
ref = new SpyChangeDetectorRef();
pipe = new AsyncPipe(ref);
pipe = new ObservablePipe(ref);
});
describe("supports", () => {