From a484163692d0df023b13badd03a412883a3a881f Mon Sep 17 00:00:00 2001 From: Dzmitry Shylovich Date: Mon, 12 Dec 2016 20:57:22 +0300 Subject: [PATCH] fix(common): add PopStateEvent interface Closes #13378 --- modules/@angular/common/src/location/location.ts | 8 +++++++- tools/public_api_guard/common/index.d.ts | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/@angular/common/src/location/location.ts b/modules/@angular/common/src/location/location.ts index e46f504bbc6b74..3aab3b25fde1f7 100644 --- a/modules/@angular/common/src/location/location.ts +++ b/modules/@angular/common/src/location/location.ts @@ -10,6 +10,12 @@ import {EventEmitter, Injectable} from '@angular/core'; import {LocationStrategy} from './location_strategy'; +/** @experimental */ +export interface PopStateEvent { + url?: string; + pop?: boolean; + type?: string; +} /** * `Location` is a service that applications can use to interact with a browser's URL. @@ -133,7 +139,7 @@ export class Location { * Subscribe to the platform's `popState` events. */ subscribe( - onNext: (value: any) => void, onThrow: (exception: any) => void = null, + onNext: (value: PopStateEvent) => void, onThrow: (exception: any) => void = null, onReturn: () => void = null): Object { return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn}); } diff --git a/tools/public_api_guard/common/index.d.ts b/tools/public_api_guard/common/index.d.ts index 6003a60e655715..cb0110f2cb09c8 100644 --- a/tools/public_api_guard/common/index.d.ts +++ b/tools/public_api_guard/common/index.d.ts @@ -74,7 +74,7 @@ export declare class Location { path(includeHash?: boolean): string; prepareExternalUrl(url: string): string; replaceState(path: string, query?: string): void; - subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): Object; + subscribe(onNext: (value: PopStateEvent) => void, onThrow?: (exception: any) => void, onReturn?: () => void): Object; static joinWithSlash(start: string, end: string): string; static normalizeQueryParams(params: string): string; static stripTrailingSlash(url: string): string; @@ -220,6 +220,13 @@ export declare abstract class PlatformLocation { abstract replaceState(state: any, title: string, url: string): void; } +/** @experimental */ +export interface PopStateEvent { + url?: string; + pop?: boolean; + type?: string; +} + /** @stable */ export declare class SlicePipe implements PipeTransform { transform(value: any, start: number, end?: number): any;