refactor(router): not use reserved words as variable (#9941)

This commit is contained in:
LongYinan
2016-07-12 01:53:29 +08:00
committed by Victor Berchet
parent 57473e72ec
commit 61e18434d3

View File

@ -13,13 +13,13 @@ import 'rxjs/add/operator/reduce';
import 'rxjs/add/operator/every'; import 'rxjs/add/operator/every';
import 'rxjs/add/observable/from'; import 'rxjs/add/observable/from';
import 'rxjs/add/observable/forkJoin'; import 'rxjs/add/observable/forkJoin';
import 'rxjs/add/observable/of';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {AppModuleFactoryLoader, ComponentFactoryResolver, ComponentResolver, Injector, ReflectiveInjector, Type} from '@angular/core'; import {AppModuleFactoryLoader, ComponentFactoryResolver, ComponentResolver, Injector, ReflectiveInjector, Type} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject'; import {Subject} from 'rxjs/Subject';
import {Subscription} from 'rxjs/Subscription'; import {Subscription} from 'rxjs/Subscription';
import {of } from 'rxjs/observable/of';
import {applyRedirects} from './apply_redirects'; import {applyRedirects} from './apply_redirects';
import {ResolveData, Routes, validateConfig} from './config'; import {ResolveData, Routes, validateConfig} from './config';
@ -347,7 +347,7 @@ export class Router {
if (shouldActivate) { if (shouldActivate) {
return preActivation.resolveData().map(() => shouldActivate); return preActivation.resolveData().map(() => shouldActivate);
} else { } else {
return of (shouldActivate); return Observable.of(shouldActivate);
} }
}) })
@ -413,7 +413,7 @@ class PreActivation {
} }
checkGuards(): Observable<boolean> { checkGuards(): Observable<boolean> {
if (this.checks.length === 0) return of (true); if (this.checks.length === 0) return Observable.of(true);
return Observable.from(this.checks) return Observable.from(this.checks)
.map(s => { .map(s => {
if (s instanceof CanActivate) { if (s instanceof CanActivate) {
@ -431,13 +431,13 @@ class PreActivation {
} }
resolveData(): Observable<any> { resolveData(): Observable<any> {
if (this.checks.length === 0) return of (null); if (this.checks.length === 0) return Observable.of(null);
return Observable.from(this.checks) return Observable.from(this.checks)
.mergeMap(s => { .mergeMap(s => {
if (s instanceof CanActivate) { if (s instanceof CanActivate) {
return this.runResolve(s.route); return this.runResolve(s.route);
} else { } else {
return of (null); return Observable.of(null);
} }
}) })
.reduce((_, __) => _); .reduce((_, __) => _);
@ -518,7 +518,7 @@ class PreActivation {
private runCanActivate(future: ActivatedRouteSnapshot): Observable<boolean> { private runCanActivate(future: ActivatedRouteSnapshot): Observable<boolean> {
const canActivate = future._routeConfig ? future._routeConfig.canActivate : null; const canActivate = future._routeConfig ? future._routeConfig.canActivate : null;
if (!canActivate || canActivate.length === 0) return of (true); if (!canActivate || canActivate.length === 0) return Observable.of(true);
return Observable.from(canActivate) return Observable.from(canActivate)
.map(c => { .map(c => {
const guard = this.injector.get(c); const guard = this.injector.get(c);
@ -534,7 +534,7 @@ class PreActivation {
private runCanDeactivate(component: Object, curr: ActivatedRouteSnapshot): Observable<boolean> { private runCanDeactivate(component: Object, curr: ActivatedRouteSnapshot): Observable<boolean> {
const canDeactivate = curr && curr._routeConfig ? curr._routeConfig.canDeactivate : null; const canDeactivate = curr && curr._routeConfig ? curr._routeConfig.canDeactivate : null;
if (!canDeactivate || canDeactivate.length === 0) return of (true); if (!canDeactivate || canDeactivate.length === 0) return Observable.of(true);
return Observable.from(canDeactivate) return Observable.from(canDeactivate)
.map(c => { .map(c => {
const guard = this.injector.get(c); const guard = this.injector.get(c);
@ -571,7 +571,7 @@ function wrapIntoObservable<T>(value: T | Observable<T>): Observable<T> {
if (value instanceof Observable) { if (value instanceof Observable) {
return value; return value;
} else { } else {
return of (value); return Observable.of(value);
} }
} }