chore(facade): remove most facade/async functions

This commit is contained in:
Jason Choi
2016-08-02 15:53:34 -07:00
committed by Alex Rickabaugh
parent 6baf3baedd
commit 99989f5d3f
184 changed files with 1609 additions and 1698 deletions

View File

@ -8,7 +8,7 @@
import {Attribute, ComponentRef, Directive, DynamicComponentLoader, OnDestroy, Output, ReflectiveInjector, ViewContainerRef, provide} from '@angular/core';
import {EventEmitter, PromiseWrapper} from '../facade/async';
import {EventEmitter} from '../facade/async';
import {StringMapWrapper} from '../facade/collection';
import {isBlank, isPresent} from '../facade/lang';
import {ComponentInstruction, RouteData, RouteParams} from '../instruction';
@ -17,7 +17,7 @@ import * as hookMod from '../lifecycle/lifecycle_annotations';
import {hasLifecycleHook} from '../lifecycle/route_lifecycle_reflector';
import * as routerMod from '../router';
let _resolveToTrue = PromiseWrapper.resolve(true);
let _resolveToTrue = Promise.resolve(true);
/**
* A router outlet is a placeholder that Angular dynamically fills based on the application's route.
@ -91,7 +91,7 @@ export class RouterOutlet implements OnDestroy {
if (isBlank(this._componentRef)) {
return this.activate(nextInstruction);
} else {
return PromiseWrapper.resolve(
return Promise.resolve(
hasLifecycleHook(hookMod.routerOnReuse, this._currentInstruction.componentType) ?
this._componentRef.then(
(ref: ComponentRef<any>) =>
@ -169,7 +169,7 @@ export class RouterOutlet implements OnDestroy {
(isPresent(nextInstruction.params) && isPresent(this._currentInstruction.params) &&
StringMapWrapper.equals(nextInstruction.params, this._currentInstruction.params));
}
return <Promise<boolean>>PromiseWrapper.resolve(result);
return <Promise<boolean>>Promise.resolve(result);
}
ngOnDestroy(): void { this._parentRouter.unregisterPrimaryOutlet(this); }

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PromiseWrapper} from '../src/facade/async';
import {StringMapWrapper} from '../src/facade/collection';
import {isBlank, isPresent, normalizeBlank} from '../src/facade/lang';
@ -229,9 +228,7 @@ export class ResolvedInstruction extends Instruction {
super(component, child, auxInstruction);
}
resolveComponent(): Promise<ComponentInstruction> {
return PromiseWrapper.resolve(this.component);
}
resolveComponent(): Promise<ComponentInstruction> { return Promise.resolve(this.component); }
}
@ -282,7 +279,7 @@ export class UnresolvedInstruction extends Instruction {
resolveComponent(): Promise<ComponentInstruction> {
if (isPresent(this.component)) {
return PromiseWrapper.resolve(this.component);
return Promise.resolve(this.component);
}
return this._resolver().then((instruction: Instruction) => {
this.child = isPresent(instruction) ? instruction.child : null;

View File

@ -6,22 +6,22 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PromiseWrapper} from '../src/facade/async';
import {ListWrapper, Map, StringMapWrapper} from '../src/facade/collection';
import {Inject, Injectable, OpaqueToken} from '@angular/core';
import {isPresent, isArray, isBlank, isType, isString, isStringMap, Type, StringWrapper, Math, getTypeNameForDebugging,} from '../src/facade/lang';
import {BaseException} from '../src/facade/exceptions';
import {Injectable, Inject, OpaqueToken} from '@angular/core';
import {RouteConfig, Route, AuxRoute, RouteDefinition} from './route_config/route_config_impl';
import {PathMatch, RedirectMatch, RouteMatch} from './rules/rules';
import {RuleSet} from './rules/rule_set';
import {Instruction, ResolvedInstruction, RedirectInstruction, UnresolvedInstruction, DefaultInstruction} from './instruction';
import {normalizeRouteConfig, assertComponentExists} from './route_config/route_config_normalizer';
import {parser, Url, convertUrlParamsToArray} from './url_parser';
import {GeneratedUrl} from './rules/route_paths/route_path';
import {reflector} from '../core_private';
import {ListWrapper, Map, StringMapWrapper} from '../src/facade/collection';
import {BaseException} from '../src/facade/exceptions';
import {Math, StringWrapper, Type, getTypeNameForDebugging, isArray, isBlank, isPresent, isString, isStringMap, isType} from '../src/facade/lang';
var _resolveToNull = PromiseWrapper.resolve<Instruction>(null);
import {DefaultInstruction, Instruction, RedirectInstruction, ResolvedInstruction, UnresolvedInstruction} from './instruction';
import {AuxRoute, Route, RouteConfig, RouteDefinition} from './route_config/route_config_impl';
import {assertComponentExists, normalizeRouteConfig} from './route_config/route_config_normalizer';
import {GeneratedUrl} from './rules/route_paths/route_path';
import {RuleSet} from './rules/rule_set';
import {PathMatch, RedirectMatch, RouteMatch} from './rules/rules';
import {Url, convertUrlParamsToArray, parser} from './url_parser';
var _resolveToNull = Promise.resolve(null);
// A LinkItemArray is an array, which describes a set of routes
// The items in the array are found in groups:
@ -200,10 +200,10 @@ export class RouteRegistry {
}));
if ((isBlank(parsedUrl) || parsedUrl.path == '') && possibleMatches.length == 0) {
return PromiseWrapper.resolve(this.generateDefault(parentComponent));
return Promise.resolve(this.generateDefault(parentComponent));
}
return PromiseWrapper.all<Instruction>(matchPromises).then(mostSpecific);
return Promise.all<Instruction>(matchPromises).then(mostSpecific);
}
private _auxRoutesToUnresolved(auxRoutes: Url[], parentInstructions: Instruction[]):

View File

@ -9,7 +9,7 @@
import {Location} from '@angular/common';
import {Inject, Injectable} from '@angular/core';
import {EventEmitter, ObservableWrapper, PromiseWrapper} from '../src/facade/async';
import {EventEmitter} from '../src/facade/async';
import {Map, StringMapWrapper} from '../src/facade/collection';
import {BaseException} from '../src/facade/exceptions';
import {Type, isBlank, isPresent} from '../src/facade/lang';
@ -20,8 +20,8 @@ import {getCanActivateHook} from './lifecycle/route_lifecycle_reflector';
import {RouteDefinition} from './route_config/route_config_impl';
import {ROUTER_PRIMARY_COMPONENT, RouteRegistry} from './route_registry';
let _resolveToTrue = PromiseWrapper.resolve(true);
let _resolveToFalse = PromiseWrapper.resolve(false);
let _resolveToTrue = Promise.resolve(true);
let _resolveToFalse = Promise.resolve(false);
/**
* The `Router` is responsible for mapping URLs to components.
@ -271,7 +271,7 @@ export class Router {
instruction.auxInstruction, (instruction: Instruction, _: any /** TODO #9100 */) => {
unsettledInstructions.push(this._settleInstruction(instruction));
});
return PromiseWrapper.all(unsettledInstructions);
return Promise.all(unsettledInstructions);
});
}
@ -296,15 +296,13 @@ export class Router {
}
private _emitNavigationFinish(instruction: ComponentInstruction): void {
ObservableWrapper.callEmit(this._subject, {status: 'success', instruction});
this._subject.emit({status: 'success', instruction});
}
/** @internal */
_emitNavigationFail(url: string): void {
ObservableWrapper.callEmit(this._subject, {status: 'fail', url});
}
_emitNavigationFail(url: string): void { this._subject.emit({status: 'fail', url}); }
private _afterPromiseFinishNavigating(promise: Promise<any>): Promise<any> {
return PromiseWrapper.catchError(promise.then((_) => this._finishNavigating()), (err) => {
return promise.then(() => this._finishNavigating()).catch((err) => {
this._finishNavigating();
throw err;
});
@ -396,7 +394,7 @@ export class Router {
}
});
return next.then((_) => PromiseWrapper.all(promises));
return next.then((_) => Promise.all(promises));
}
@ -411,7 +409,7 @@ export class Router {
* Subscribe to URL updates from the router
*/
subscribe(onNext: (value: any) => void, onError?: (value: any) => void): Object {
return ObservableWrapper.subscribe(this._subject, onNext, onError);
return this._subject.subscribe({next: onNext, error: onError});
}
@ -552,7 +550,7 @@ export class RootRouter extends Router {
dispose(): void {
if (isPresent(this._locationSub)) {
ObservableWrapper.dispose(this._locationSub);
(<any>this._locationSub).unsubscribe();
this._locationSub = null;
}
}

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PromiseWrapper} from '../../facade/async';
import {Type, isPresent} from '../../facade/lang';
import {BLANK_ROUTE_DATA, RouteData} from '../../instruction';
@ -20,7 +19,7 @@ export class SyncRouteHandler implements RouteHandler {
_resolvedComponent: Promise<any> = null;
constructor(public componentType: Type, data?: {[key: string]: any}) {
this._resolvedComponent = PromiseWrapper.resolve(componentType);
this._resolvedComponent = Promise.resolve(componentType);
this.data = isPresent(data) ? new RouteData(data) : BLANK_ROUTE_DATA;
}

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PromiseWrapper} from '../facade/async';
import {Map} from '../facade/collection';
import {BaseException} from '../facade/exceptions';
import {isBlank, isFunction, isPresent} from '../facade/lang';
@ -120,7 +119,7 @@ export class RuleSet {
// handle cases where we are routing just to an aux route
if (solutions.length == 0 && isPresent(urlParse) && urlParse.auxiliary.length > 0) {
return [PromiseWrapper.resolve(new PathMatch(null, null, urlParse.auxiliary))];
return [Promise.resolve(new PathMatch(null, null, urlParse.auxiliary))];
}
return solutions;
@ -132,7 +131,7 @@ export class RuleSet {
return [routeRecognizer.recognize(urlParse)];
}
return [PromiseWrapper.resolve(null)];
return [Promise.resolve(null)];
}
hasRoute(name: string): boolean { return this.rulesByName.has(name); }

View File

@ -9,7 +9,6 @@
import {Map} from '../facade/collection';
import {BaseException} from '../facade/exceptions';
import {isBlank, isPresent} from '../facade/lang';
import {PromiseWrapper} from '../facade/promise';
import {ComponentInstruction} from '../instruction';
import {Url, convertUrlParamsToArray} from '../url_parser';
@ -58,7 +57,7 @@ export class RedirectRule implements AbstractRule {
if (isPresent(this._pathRecognizer.matchUrl(beginningSegment))) {
match = new RedirectMatch(this.redirectTo, this._pathRecognizer.specificity);
}
return PromiseWrapper.resolve(match);
return Promise.resolve(match);
}
generate(params: {[key: string]: any}): ComponentInstruction {

View File

@ -6,16 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing';
import {SpyRouter, SpyLocation} from '../spies';
import {Component} from '@angular/core';
import {Location} from '@angular/common';
import {Router, RouteRegistry, RouterLink, RouterOutlet, Route, RouteParams, ComponentInstruction} from '@angular/router-deprecated';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {ResolvedInstruction} from '@angular/router-deprecated/src/instruction';
import {Component} from '@angular/core';
import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {ComponentInstruction, Route, RouteParams, RouteRegistry, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
import {ResolvedInstruction} from '@angular/router-deprecated/src/instruction';
import {SpyLocation, SpyRouter} from '../spies';
let dummyInstruction = new ResolvedInstruction(
new ComponentInstruction('detail', [], null, null, true, '0', null, 'Detail'), null, {});

View File

@ -6,11 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {TEST_ROUTER_PROVIDERS, ddescribeRouter, describeRouter, describeWith, describeWithAndWithout, describeWithout, itShouldRoute} from './util';
import {beforeEachProviders, describe,} from '@angular/core/testing/testing_internal';
import {beforeEachProviders, describe} from '@angular/core/testing/testing_internal';
import {registerSpecs} from './impl/aux_route_spec_impl';
import {TEST_ROUTER_PROVIDERS, ddescribeRouter, describeRouter, describeWith, describeWithAndWithout, describeWithout, itShouldRoute} from './util';
export function main() {
describe('auxiliary route spec', () => {

View File

@ -19,8 +19,6 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
import {expect} from '@angular/platform-browser/testing/matchers';
import {ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT, ROUTER_PROVIDERS, RouteParams, Router} from '@angular/router-deprecated';
import {PromiseWrapper} from '../../src/facade/async';
import {BaseException} from '../../src/facade/exceptions';
import {AuxRoute, Route, RouteConfig} from '../../src/route_config/route_config_decorator';
@ -74,7 +72,7 @@ export function main() {
(async: AsyncTestCompleter, tcb: TestComponentBuilder) => {
tcb.createAsync(AppCmp).then((fixture) => {
var router = fixture.debugElement.componentInstance.router;
PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
router.navigateByUrl('/cause-error').catch((error: any) => {
expect(error).toContainError('oops!');
async.done();
});

View File

@ -6,18 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, beforeEach, beforeEachProviders, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {Location} from '@angular/common';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {AsyncRoute, Route, Router} from '@angular/router-deprecated';
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
import {Router, AsyncRoute, Route} from '@angular/router-deprecated';
import {HelloCmp, helloCmpLoader, UserCmp, userCmpLoader, TeamCmp, asyncTeamLoader, ParentCmp, parentCmpLoader, asyncParentCmpLoader, asyncDefaultParentCmpLoader, ParentWithDefaultCmp, parentWithDefaultCmpLoader, asyncRouteDataCmp} from './fixture_components';
import {By} from '../../../../platform-browser/src/dom/debug/by';
import {TEST_ROUTER_PROVIDERS, clickOnElement, compile, getHref, specs} from '../util';
import {HelloCmp, ParentCmp, ParentWithDefaultCmp, TeamCmp, UserCmp, asyncDefaultParentCmpLoader, asyncParentCmpLoader, asyncRouteDataCmp, asyncTeamLoader, helloCmpLoader, parentCmpLoader, parentWithDefaultCmpLoader, userCmpLoader} from './fixture_components';
function getLinkElement(rtc: ComponentFixture<any>) {
return rtc.debugElement.query(By.css('a')).nativeElement;

View File

@ -9,8 +9,6 @@
import {Component, ComponentRef, ViewChild, ViewContainerRef} from '@angular/core';
import {DynamicComponentLoader} from '@angular/core/src/linker/dynamic_component_loader';
import {AsyncRoute, ROUTER_DIRECTIVES, Redirect, Route, RouteConfig, RouteData, RouteParams} from '@angular/router-deprecated';
import {PromiseWrapper} from '../../../src/facade/async';
import {isPresent} from '../../../src/facade/lang';
@Component({selector: 'goodbye-cmp', template: `{{farewell}}`})
@ -26,7 +24,7 @@ export class HelloCmp {
}
export function helloCmpLoader() {
return PromiseWrapper.resolve(HelloCmp);
return Promise.resolve(HelloCmp);
}
@ -37,7 +35,7 @@ export class UserCmp {
}
export function userCmpLoader() {
return PromiseWrapper.resolve(UserCmp);
return Promise.resolve(UserCmp);
}
@ -51,7 +49,7 @@ export class ParentCmp {
}
export function parentCmpLoader() {
return PromiseWrapper.resolve(ParentCmp);
return Promise.resolve(ParentCmp);
}
@ -65,7 +63,7 @@ export class AsyncParentCmp {
}
export function asyncParentCmpLoader() {
return PromiseWrapper.resolve(AsyncParentCmp);
return Promise.resolve(AsyncParentCmp);
}
@Component({
@ -79,7 +77,7 @@ export class AsyncDefaultParentCmp {
}
export function asyncDefaultParentCmpLoader() {
return PromiseWrapper.resolve(AsyncDefaultParentCmp);
return Promise.resolve(AsyncDefaultParentCmp);
}
@ -93,7 +91,7 @@ export class ParentWithDefaultCmp {
}
export function parentWithDefaultCmpLoader() {
return PromiseWrapper.resolve(ParentWithDefaultCmp);
return Promise.resolve(ParentWithDefaultCmp);
}
@ -120,7 +118,7 @@ export class AsyncTeamCmp {
}
export function asyncTeamLoader() {
return PromiseWrapper.resolve(AsyncTeamCmp);
return Promise.resolve(AsyncTeamCmp);
}
@ -131,7 +129,7 @@ export class RouteDataCmp {
}
export function asyncRouteDataCmp() {
return PromiseWrapper.resolve(RouteDataCmp);
return Promise.resolve(RouteDataCmp);
}
@Component({selector: 'redirect-to-parent-cmp', template: 'redirect-to-parent'})

View File

@ -6,16 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, beforeEach, beforeEachProviders, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
import {Location} from '@angular/common';
import {Router, Route} from '@angular/router-deprecated';
import {HelloCmp, UserCmp, TeamCmp, ParentCmp, ParentWithDefaultCmp, DynamicLoaderCmp} from './fixture_components';
import {PromiseWrapper} from '../../../src/facade/async';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {expect} from '@angular/platform-browser/testing/matchers';
import {Route, Router} from '@angular/router-deprecated';
import {TEST_ROUTER_PROVIDERS, clickOnElement, compile, getHref, specs} from '../util';
import {DynamicLoaderCmp, HelloCmp, ParentCmp, ParentWithDefaultCmp, TeamCmp, UserCmp} from './fixture_components';
function getLinkElement(rtc: ComponentFixture<any>) {
@ -497,7 +496,7 @@ function syncRoutesWithDynamicComponents() {
// something
// similar basically the assertion needs to run when the world is
// stable and we don't know when that is, only zones know.
PromiseWrapper.resolve(null).then((_) => {
Promise.resolve(null).then((_) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
async.done();

View File

@ -6,13 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component,} from '@angular/core';
import {Component} from '@angular/core';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
import {EventEmitter, ObservableWrapper, PromiseCompleter, PromiseWrapper} from '../../src/facade/async';
import {EventEmitter} from '../../src/facade/async';
import {isPresent} from '../../src/facade/lang';
import {ComponentInstruction} from '../../src/instruction';
import {CanDeactivate, CanReuse, OnActivate, OnDeactivate, OnReuse} from '../../src/interfaces';
@ -24,7 +24,9 @@ import {TEST_ROUTER_PROVIDERS, compile} from './util';
var cmpInstanceCount: any /** TODO #9100 */;
var log: string[];
var eventBus: EventEmitter<any>;
var completer: PromiseCompleter<any>;
var resolve: (result: any) => void;
var reject: (error: any) => void;
var promise: Promise<any>;
export function main() {
describe('Router lifecycle hooks', () => {
@ -64,9 +66,11 @@ export function main() {
.then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => {
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('parent activate')) {
completer.resolve(true);
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('parent activate')) {
resolve(true);
}
}
});
rtr.navigateByUrl('/parent-activate/child-activate').then((_) => {
@ -102,11 +106,14 @@ export function main() {
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/parent-deactivate/child-deactivate'))
.then((_) => {
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('deactivate')) {
completer.resolve(true);
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('parent [deactivate cmp]');
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('deactivate')) {
resolve(true);
fixture.detectChanges();
expect(fixture.debugElement.nativeElement)
.toHaveText('parent [deactivate cmp]');
}
}
});
rtr.navigateByUrl('/a').then((_) => {
@ -173,9 +180,11 @@ export function main() {
.then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => {
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('routerCanActivate')) {
completer.resolve(true);
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('routerCanActivate')) {
resolve(true);
}
}
});
rtr.navigateByUrl('/can-activate/a').then((_) => {
@ -193,9 +202,11 @@ export function main() {
.then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => {
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('routerCanActivate')) {
completer.resolve(false);
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('routerCanActivate')) {
resolve(false);
}
}
});
rtr.navigateByUrl('/can-activate/a').then((_) => {
@ -218,9 +229,11 @@ export function main() {
expect(fixture.debugElement.nativeElement).toHaveText('routerCanDeactivate [A]');
expect(log).toEqual([]);
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('routerCanDeactivate')) {
completer.resolve(true);
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('routerCanDeactivate')) {
resolve(true);
}
}
});
@ -244,9 +257,11 @@ export function main() {
expect(fixture.debugElement.nativeElement).toHaveText('routerCanDeactivate [A]');
expect(log).toEqual([]);
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('routerCanDeactivate')) {
completer.resolve(false);
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('routerCanDeactivate')) {
resolve(false);
}
}
});
@ -300,9 +315,11 @@ export function main() {
'routerOnActivate: null -> /reuse-hooks/1'
]);
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('routerCanReuse')) {
completer.resolve(true);
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('routerCanReuse')) {
resolve(true);
}
}
});
@ -330,9 +347,11 @@ export function main() {
'routerOnActivate: null -> /reuse-hooks/1'
]);
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
if (ev.startsWith('routerCanReuse')) {
completer.resolve(false);
eventBus.subscribe({
next: (ev: any) => {
if (ev.startsWith('routerCanReuse')) {
resolve(false);
}
}
});
@ -368,7 +387,7 @@ function logHook(name: string, next: ComponentInstruction, prev: ComponentInstru
var message = name + ': ' + (isPresent(prev) ? ('/' + prev.urlPath) : 'null') + ' -> ' +
(isPresent(next) ? ('/' + next.urlPath) : 'null');
log.push(message);
ObservableWrapper.callEmit(eventBus, message);
eventBus.emit(message);
}
@Component({selector: 'activate-cmp', template: 'activate cmp'})
@ -386,9 +405,12 @@ class ActivateCmp implements OnActivate {
@RouteConfig([new Route({path: '/child-activate', component: ActivateCmp})])
class ParentActivateCmp implements OnActivate {
routerOnActivate(next: ComponentInstruction, prev: ComponentInstruction): Promise<any> {
completer = PromiseWrapper.completer();
promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
logHook('parent activate', next, prev);
return completer.promise;
return promise;
}
}
@ -402,9 +424,12 @@ class DeactivateCmp implements OnDeactivate {
@Component({selector: 'deactivate-cmp', template: 'deactivate cmp'})
class WaitDeactivateCmp implements OnDeactivate {
routerOnDeactivate(next: ComponentInstruction, prev: ComponentInstruction): Promise<any> {
completer = PromiseWrapper.completer();
promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
logHook('deactivate', next, prev);
return completer.promise;
return promise;
}
}
@ -460,9 +485,12 @@ class NeverReuseCmp implements OnReuse,
class CanActivateCmp {
static routerCanActivate(next: ComponentInstruction, prev: ComponentInstruction):
Promise<boolean> {
completer = PromiseWrapper.completer();
promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
logHook('routerCanActivate', next, prev);
return completer.promise;
return promise;
}
}
@ -474,9 +502,12 @@ class CanActivateCmp {
@RouteConfig([new Route({path: '/a', component: A}), new Route({path: '/b', component: B})])
class CanDeactivateCmp implements CanDeactivate {
routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction): Promise<boolean> {
completer = PromiseWrapper.completer();
promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
logHook('routerCanDeactivate', next, prev);
return completer.promise;
return promise;
}
}
@ -534,9 +565,12 @@ class AllHooksParentCmp implements CanDeactivate,
@CanActivate(ReuseHooksCmp.routerCanActivate)
class ReuseHooksCmp implements OnActivate, OnReuse, OnDeactivate, CanReuse, CanDeactivate {
routerCanReuse(next: ComponentInstruction, prev: ComponentInstruction): Promise<any> {
completer = PromiseWrapper.completer();
promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
logHook('routerCanReuse', next, prev);
return completer.promise;
return promise;
}
routerOnReuse(next: ComponentInstruction, prev: ComponentInstruction) {

View File

@ -13,7 +13,6 @@ import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe
import {expect} from '@angular/platform-browser/testing/matchers';
import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
import {PromiseWrapper, TimerWrapper} from '../../src/facade/async';
import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator';
import {RootCmp, TEST_ROUTER_PROVIDERS, compile} from './util';
@ -238,9 +237,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/test'))
.then((_) => {
// Note: need a timeout so that all promises are flushed
var completer = PromiseWrapper.completer();
TimerWrapper.setTimeout(() => { completer.resolve(null); }, 0);
return completer.promise;
return new Promise(resolve => { setTimeout(() => { resolve(null); }, 0); });
})
.then((_) => {
expect(fixture.componentInstance.activatedCmp).toBeAnInstanceOf(HelloCmp);
@ -259,7 +256,7 @@ class HelloCmp {
function asyncRouteDataCmp() {
return PromiseWrapper.resolve(RouteDataCmp);
return Promise.resolve(RouteDataCmp);
}
@Component({selector: 'data-cmp', template: `{{myData}}`})
@ -279,7 +276,7 @@ class UserCmp {
function parentLoader() {
return PromiseWrapper.resolve(ParentCmp);
return Promise.resolve(ParentCmp);
}
@Component({

View File

@ -6,19 +6,18 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {Location} from '@angular/common';
import {NumberWrapper, escapeRegExp} from '../../src/facade/lang';
import {PromiseWrapper} from '../../src/facade/async';
import {ListWrapper} from '../../src/facade/collection';
import {Component} from '@angular/core';
import {Router, RouteRegistry, RouterLink, AsyncRoute, AuxRoute, Route, RouteParams, RouteConfig, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT} from '@angular/router-deprecated';
import {RootRouter} from '@angular/router-deprecated/src/router';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {SpyLocation} from '@angular/common/testing';
import {Component} from '@angular/core';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {expect} from '@angular/platform-browser/testing/matchers';
import {AsyncRoute, AuxRoute, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT, Route, RouteConfig, RouteParams, RouteRegistry, Router, RouterLink} from '@angular/router-deprecated';
import {RootRouter} from '@angular/router-deprecated/src/router';
import {ListWrapper} from '../../src/facade/collection';
import {NumberWrapper, escapeRegExp} from '../../src/facade/lang';
export function main() {
describe('routerLink directive', function() {
@ -435,7 +434,7 @@ class Hello2Cmp {
}
function parentCmpLoader() {
return PromiseWrapper.resolve(ParentCmp);
return Promise.resolve(ParentCmp);
}
@Component({

View File

@ -6,11 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {APP_BASE_HREF, HashLocationStrategy, PlatformLocation} from '@angular/common';
import {Injector, provide} from '@angular/core';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
import {PlatformLocation, APP_BASE_HREF, HashLocationStrategy} from '@angular/common';
import {SpyPlatformLocation} from '../spies';
export function main() {

View File

@ -6,11 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {ReflectiveInjector} from '@angular/core';
import {Location, LocationStrategy} from '@angular/common';
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
import {ReflectiveInjector} from '@angular/core';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
export function main() {
describe('Location', () => {

View File

@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {APP_BASE_HREF, LocationStrategy, PathLocationStrategy, PlatformLocation} from '@angular/common';
import {Injector, provide} from '@angular/core';
import {PlatformLocation, LocationStrategy, PathLocationStrategy, APP_BASE_HREF} from '@angular/common';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
import {SpyPlatformLocation} from '../spies';
export function main() {

View File

@ -6,18 +6,17 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, beforeEach, ddescribe, describe, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {LocationStrategy} from '@angular/common';
import {Component, Directive} from '@angular/core/src/metadata';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {Console} from '@angular/core/src/console';
import {ExceptionHandler, disposePlatform} from '@angular/core';
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
import {ROUTER_PROVIDERS, Router, RouteConfig, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
import {ExceptionHandler, disposePlatform} from '@angular/core';
import {Console} from '@angular/core/src/console';
import {Component, Directive} from '@angular/core/src/metadata';
import {AsyncTestCompleter, beforeEach, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
import {expect} from '@angular/platform-browser/testing/matchers';
import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig, Router} from '@angular/router-deprecated';
class _ArrayLogger {
res: any[] = [];

View File

@ -6,13 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
import {PromiseWrapper} from '../src/facade/async';
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
import {Type} from '../src/facade/lang';
import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../src/route_config/route_config_decorator';
import {RouteRegistry} from '../src/route_registry';
import {RouteConfig, Route, Redirect, AuxRoute, AsyncRoute} from '../src/route_config/route_config_decorator';
export function main() {
@ -322,11 +319,11 @@ function stringifyInstruction(instruction: any /** TODO #9100 */): string {
function asyncParentLoader() {
return PromiseWrapper.resolve(DummyParentCmp);
return Promise.resolve(DummyParentCmp);
}
function asyncChildLoader() {
return PromiseWrapper.resolve(DummyCmpB);
return Promise.resolve(DummyCmpB);
}
class RootHostCmp {}

View File

@ -12,7 +12,6 @@ import {provide} from '@angular/core';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {RouterOutlet} from '../src/directives/router_outlet';
import {ObservableWrapper, PromiseWrapper} from '../src/facade/async';
import {ListWrapper} from '../src/facade/collection';
import {Type} from '../src/facade/lang';
import {AsyncRoute, Redirect, Route, RouteConfig} from '../src/route_config/route_config_decorator';
@ -194,7 +193,7 @@ export function main() {
it('should, when subscribed to, return a disposable subscription', () => {
expect(() => {
var subscription = router.subscribe((_) => {});
ObservableWrapper.dispose(subscription);
(<any>subscription).unsubscribe();
}).not.toThrow();
});
@ -326,7 +325,7 @@ function stringifyInstruction(instruction: any /** TODO #9100 */): string {
}
function loader(): Promise<Type> {
return PromiseWrapper.resolve(DummyComponent);
return Promise.resolve(DummyComponent);
}
class DummyComponent {}
@ -337,12 +336,10 @@ class DummyParentComp {
function makeDummyOutlet(): RouterOutlet {
var ref = new SpyRouterOutlet();
ref.spy('canActivate').andCallFake((_: any /** TODO #9100 */) => PromiseWrapper.resolve(true));
ref.spy('routerCanReuse')
.andCallFake((_: any /** TODO #9100 */) => PromiseWrapper.resolve(false));
ref.spy('routerCanDeactivate')
.andCallFake((_: any /** TODO #9100 */) => PromiseWrapper.resolve(true));
ref.spy('activate').andCallFake((_: any /** TODO #9100 */) => PromiseWrapper.resolve(true));
ref.spy('canActivate').andCallFake((_: any /** TODO #9100 */) => Promise.resolve(true));
ref.spy('routerCanReuse').andCallFake((_: any /** TODO #9100 */) => Promise.resolve(false));
ref.spy('routerCanDeactivate').andCallFake((_: any /** TODO #9100 */) => Promise.resolve(true));
ref.spy('activate').andCallFake((_: any /** TODO #9100 */) => Promise.resolve(true));
return <any>ref;
}

View File

@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
import {beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
import {ParamRoutePath} from '../../../src/rules/route_paths/param_route_path';
import {parser, Url} from '../../../src/url_parser';
import {Url, parser} from '../../../src/url_parser';
export function main() {
describe('PathRecognizer', () => {

View File

@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
import {beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
import {GeneratedUrl} from '../../../src/rules/route_paths/route_path';
import {RegexRoutePath} from '../../../src/rules/route_paths/regex_route_path';
import {GeneratedUrl} from '../../../src/rules/route_paths/route_path';
import {parser} from '../../../src/url_parser';
function emptySerializer(params: any /** TODO #9100 */) {

View File

@ -6,14 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AsyncTestCompleter, describe, it, iit, ddescribe, inject, beforeEach,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter, beforeEach, ddescribe, describe, iit, inject, it} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers';
import {RouteMatch, PathMatch, RedirectMatch} from '../../src/rules/rules';
import {RuleSet} from '../../src/rules/rule_set';
import {Redirect, Route} from '../../src/route_config/route_config_decorator';
import {GeneratedUrl} from '../../src/rules/route_paths/route_path';
import {Route, Redirect} from '../../src/route_config/route_config_decorator';
import {RuleSet} from '../../src/rules/rule_set';
import {PathMatch, RedirectMatch, RouteMatch} from '../../src/rules/rules';
import {parser} from '../../src/url_parser';
import {PromiseWrapper} from '../../src/facade/promise';
export function main() {
@ -248,7 +247,7 @@ export function main() {
function recognize(recognizer: RuleSet, url: string): Promise<RouteMatch[]> {
var parsedUrl = parser.parse(url);
return PromiseWrapper.all(recognizer.recognize(parsedUrl));
return Promise.all(recognizer.recognize(parsedUrl));
}
function getComponentType(routeMatch: RouteMatch): any {

View File

@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
import {beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
import {UrlParser, Url} from '../src/url_parser';
import {Url, UrlParser} from '../src/url_parser';
export function main() {