feat(frame): add navigatingTo and navigatedTo events (#9025)

This commit is contained in:
Martin Guillon
2020-11-13 05:51:03 +01:00
committed by GitHub
parent cb61c2aa7e
commit cf96e7252c
2 changed files with 30 additions and 1 deletions

View File

@ -249,6 +249,12 @@ export class FrameBase extends CustomLayoutView {
}
newPage.onNavigatedTo(isBack);
this.notify({
eventName: Page.navigatedToEvent,
object: this,
isBack,
entry,
});
// Reset executing context after NavigatedTo is raised;
// we do not want to execute two navigations in parallel in case
@ -417,6 +423,13 @@ export class FrameBase extends CustomLayoutView {
}
backstackEntry.resolvedPage.onNavigatingTo(backstackEntry.entry.context, isBack, backstackEntry.entry.bindingContext);
this.notify({
eventName: Page.navigatingToEvent,
object: this,
isBack,
entry: backstackEntry.entry,
fromEntry:this.currentEntry
});
}
public get animated(): boolean {

View File

@ -1,11 +1,17 @@
import { NavigationType, FrameBase } from './frame-common';
import { Page } from '../page';
import { NavigatedData, Page } from '../page';
import { Observable, EventData } from '../../data/observable';
import { View } from '../core/view';
import { Transition } from '../transition';
export * from './frame-interfaces';
export interface NavigationData extends EventData {
entry?: NavigationEntry;
fromEntry?: NavigationEntry;
isBack?: boolean;
}
/**
* Represents the logical View unit that is responsible for navigation within an application.
* Nested frames are supported, enabling hierarchical navigation scenarios.
@ -210,6 +216,16 @@ export class Frame extends FrameBase {
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(eventNames: string, callback: (args: EventData) => void, thisArg?: any);
/**
* Raised when navigation to the page has started.
*/
public on(event: 'navigatingTo', callback: (args: NavigationData) => void, thisArg?: any);
/**
* Raised when navigation to the page has finished.
*/
public on(event: 'navigatedTo', callback: (args: NavigationData) => void, thisArg?: any);
}
/**