Skip to content

Commit fe44118

Browse files
Dzmitry Shylovichmhevery
authored andcommitted
fix(common): add PopStateEvent interface (angular#13400)
Closes angular#13378 PR Close angular#13400
1 parent f89d004 commit fe44118

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎modules/@angular/common/src/location/location.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import {EventEmitter, Injectable} from '@angular/core';
1010

1111
import {LocationStrategy} from './location_strategy';
1212

13+
/** @experimental */
14+
export interface PopStateEvent {
15+
pop?: boolean;
16+
type?: string;
17+
url?: string;
18+
}
1319

1420
/**
1521
* @whatItDoes `Location` is a service that applications can use to interact with a browser's URL.
@@ -122,7 +128,7 @@ export class Location {
122128
* Subscribe to the platform's `popState` events.
123129
*/
124130
subscribe(
125-
onNext: (value: any) => void, onThrow: (exception: any) => void = null,
131+
onNext: (value: PopStateEvent) => void, onThrow: (exception: any) => void = null,
126132
onReturn: () => void = null): Object {
127133
return this._subject.subscribe({next: onNext, error: onThrow, complete: onReturn});
128134
}

‎tools/public_api_guard/common/index.d.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export declare class Location {
7474
path(includeHash?: boolean): string;
7575
prepareExternalUrl(url: string): string;
7676
replaceState(path: string, query?: string): void;
77-
subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): Object;
77+
subscribe(onNext: (value: PopStateEvent) => void, onThrow?: (exception: any) => void, onReturn?: () => void): Object;
7878
static joinWithSlash(start: string, end: string): string;
7979
static normalizeQueryParams(params: string): string;
8080
static stripTrailingSlash(url: string): string;
@@ -239,6 +239,13 @@ export declare abstract class PlatformLocation {
239239
abstract replaceState(state: any, title: string, url: string): void;
240240
}
241241

242+
/** @experimental */
243+
export interface PopStateEvent {
244+
pop?: boolean;
245+
type?: string;
246+
url?: string;
247+
}
248+
242249
/** @stable */
243250
export declare class SlicePipe implements PipeTransform {
244251
transform(value: any, start: number, end?: number): any;

0 commit comments

Comments
 (0)