feat(router): add navigationSource and restoredState to NavigationStart event (#21728)
Currently, NavigationStart there is no way to know if an navigation was triggered imperatively or via the location change. These two use cases should be handled differently for a variety of use cases (e.g., scroll position restoration). This PR adds a navigation source field and restored navigation id (passed to navigations triggered by a URL change). PR Close #21728
This commit is contained in:
6
tools/public_api_guard/common/common.d.ts
vendored
6
tools/public_api_guard/common/common.d.ts
vendored
@ -182,12 +182,12 @@ export declare class Location {
|
||||
constructor(platformStrategy: LocationStrategy);
|
||||
back(): void;
|
||||
forward(): void;
|
||||
go(path: string, query?: string): void;
|
||||
go(path: string, query?: string, state?: any): void;
|
||||
isCurrentPathEqualTo(path: string, query?: string): boolean;
|
||||
normalize(url: string): string;
|
||||
path(includeHash?: boolean): string;
|
||||
prepareExternalUrl(url: string): string;
|
||||
replaceState(path: string, query?: string): void;
|
||||
replaceState(path: string, query?: string, state?: any): void;
|
||||
subscribe(onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void) | null, onReturn?: (() => void) | null): ISubscription;
|
||||
static joinWithSlash(start: string, end: string): string;
|
||||
static normalizeQueryParams(params: string): string;
|
||||
@ -199,6 +199,7 @@ export declare const LOCATION_INITIALIZED: InjectionToken<Promise<any>>;
|
||||
|
||||
/** @experimental */
|
||||
export interface LocationChangeEvent {
|
||||
state: any;
|
||||
type: string;
|
||||
}
|
||||
|
||||
@ -415,6 +416,7 @@ export declare enum Plural {
|
||||
/** @experimental */
|
||||
export interface PopStateEvent {
|
||||
pop?: boolean;
|
||||
state?: any;
|
||||
type?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
4
tools/public_api_guard/common/testing.d.ts
vendored
4
tools/public_api_guard/common/testing.d.ts
vendored
@ -21,12 +21,12 @@ export declare class SpyLocation implements Location {
|
||||
urlChanges: string[];
|
||||
back(): void;
|
||||
forward(): void;
|
||||
go(path: string, query?: string): void;
|
||||
go(path: string, query?: string, state?: any): void;
|
||||
isCurrentPathEqualTo(path: string, query?: string): boolean;
|
||||
normalize(url: string): string;
|
||||
path(): string;
|
||||
prepareExternalUrl(url: string): string;
|
||||
replaceState(path: string, query?: string): void;
|
||||
replaceState(path: string, query?: string, state?: any): void;
|
||||
setBaseHref(url: string): void;
|
||||
setInitialPath(url: string): void;
|
||||
simulateHashChange(pathname: string): void;
|
||||
|
Reference in New Issue
Block a user