fix(common): return ISubscription from Location.subscribe() (#20429)

Fix #20406

PR Close #20429
This commit is contained in:
Jason Aden 2017-11-14 10:41:37 -08:00 committed by Miško Hevery
parent ac93f1235e
commit 437a0446e2
5 changed files with 8 additions and 5 deletions

View File

@ -7,6 +7,7 @@
*/ */
import {EventEmitter, Injectable} from '@angular/core'; import {EventEmitter, Injectable} from '@angular/core';
import {ISubscription} from 'rxjs/Subscription';
import {LocationStrategy} from './location_strategy'; import {LocationStrategy} from './location_strategy';
@ -129,7 +130,7 @@ export class Location {
*/ */
subscribe( subscribe(
onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void)|null, onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void)|null,
onReturn?: (() => void)|null): Object { onReturn?: (() => void)|null): ISubscription {
return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn}); return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn});
} }

View File

@ -13,7 +13,8 @@ const globals = {
'@angular/core': 'ng.core', '@angular/core': 'ng.core',
'@angular/common': 'ng.common', '@angular/common': 'ng.common',
'rxjs/Observable': 'Rx', 'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx' 'rxjs/Subject': 'Rx',
'rxjs/Subscription': 'Rx'
}; };
module.exports = { module.exports = {

View File

@ -8,6 +8,7 @@
import {Location, LocationStrategy} from '@angular/common'; import {Location, LocationStrategy} from '@angular/common';
import {EventEmitter, Injectable} from '@angular/core'; import {EventEmitter, Injectable} from '@angular/core';
import {ISubscription} from 'rxjs/Subscription';
/** /**
@ -109,7 +110,7 @@ export class SpyLocation implements Location {
subscribe( subscribe(
onNext: (value: any) => void, onThrow?: ((error: any) => void)|null, onNext: (value: any) => void, onThrow?: ((error: any) => void)|null,
onReturn?: (() => void)|null): Object { onReturn?: (() => void)|null): ISubscription {
return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn}); return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn});
} }

View File

@ -190,7 +190,7 @@ export declare class Location {
path(includeHash?: boolean): string; path(includeHash?: boolean): string;
prepareExternalUrl(url: string): string; prepareExternalUrl(url: string): string;
replaceState(path: string, query?: string): void; replaceState(path: string, query?: string): void;
subscribe(onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void) | null, onReturn?: (() => void) | null): Object; subscribe(onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void) | null, onReturn?: (() => void) | null): ISubscription;
static joinWithSlash(start: string, end: string): string; static joinWithSlash(start: string, end: string): string;
static normalizeQueryParams(params: string): string; static normalizeQueryParams(params: string): string;
static stripTrailingSlash(url: string): string; static stripTrailingSlash(url: string): string;

View File

@ -31,5 +31,5 @@ export declare class SpyLocation implements Location {
setInitialPath(url: string): void; setInitialPath(url: string): void;
simulateHashChange(pathname: string): void; simulateHashChange(pathname: string): void;
simulateUrlPop(pathname: string): void; simulateUrlPop(pathname: string): void;
subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): Object; subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): ISubscription;
} }