Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(common): add PopStateEvent interface #13400

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion modules/@angular/common/src/location/location.ts
Expand Up @@ -10,6 +10,12 @@ import {EventEmitter, Injectable} from '@angular/core';

import {LocationStrategy} from './location_strategy';

/** @experimental */
export interface PopStateEvent {
pop?: boolean;
type?: string;
url?: string;
}

/**
* `Location` is a service that applications can use to interact with a browser's URL.
Expand Down Expand Up @@ -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});
}
Expand Down
9 changes: 8 additions & 1 deletion tools/public_api_guard/common/index.d.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -220,6 +220,13 @@ export declare abstract class PlatformLocation {
abstract replaceState(state: any, title: string, url: string): void;
}

/** @experimental */
export interface PopStateEvent {
pop?: boolean;
type?: string;
url?: string;
}

/** @stable */
export declare class SlicePipe implements PipeTransform {
transform(value: any, start: number, end?: number): any;
Expand Down