From 5691063ba0c8ebfea3cab43f567e0e5d04f4e0fa Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Mon, 11 May 2015 14:25:27 -0700 Subject: [PATCH] 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. --- modules/angular2/src/change_detection/change_detection.ts | 6 ++++-- .../pipes/{async_pipe.ts => observable_pipe.ts} | 8 ++++---- .../pipes/{async_pipe_spec.js => observable_pipe_spec.js} | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) rename modules/angular2/src/change_detection/pipes/{async_pipe.ts => observable_pipe.ts} (92%) rename modules/angular2/test/change_detection/pipes/{async_pipe_spec.js => observable_pipe_spec.js} (95%) diff --git a/modules/angular2/src/change_detection/change_detection.ts b/modules/angular2/src/change_detection/change_detection.ts index 12dabe6959..8a792c982c 100644 --- a/modules/angular2/src/change_detection/change_detection.ts +++ b/modules/angular2/src/change_detection/change_detection.ts @@ -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, diff --git a/modules/angular2/src/change_detection/pipes/async_pipe.ts b/modules/angular2/src/change_detection/pipes/observable_pipe.ts similarity index 92% rename from modules/angular2/src/change_detection/pipes/async_pipe.ts rename to modules/angular2/src/change_detection/pipes/observable_pipe.ts index 518ae8988b..c699173354 100644 --- a/modules/angular2/src/change_detection/pipes/async_pipe.ts +++ b/modules/angular2/src/change_detection/pipes/observable_pipe.ts @@ -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); } } \ No newline at end of file diff --git a/modules/angular2/test/change_detection/pipes/async_pipe_spec.js b/modules/angular2/test/change_detection/pipes/observable_pipe_spec.js similarity index 95% rename from modules/angular2/test/change_detection/pipes/async_pipe_spec.js rename to modules/angular2/test/change_detection/pipes/observable_pipe_spec.js index 7a73b19099..e54c0ef13d 100644 --- a/modules/angular2/test/change_detection/pipes/async_pipe_spec.js +++ b/modules/angular2/test/change_detection/pipes/observable_pipe_spec.js @@ -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", () => {