Editar

Partilhar via


NavigationAPI interface

Extends

NavigationAPI$1

Methods

openBrowserTab(OpenBrowserTabParams)

Opens a new browser tab and navigates to the given route path

Example

// Open https://www.example.com in a new browser
await workloadClient.navigation.openBrowserTab( {path: 'https://www.example.com' });

Inherited Methods

navigate<T>(T, (T extends "host" ? NavigationHostRoute : NavigationWorkloadRoute))

Navigates the target app to the given route path

Example

// Navigate to `/home` route of the host app
await workloadClient.navigation.navigate('host', '/home');

// Navigate to `/some/internal/path` route of the workload app
await workloadClient.navigation.navigate('workload', '/some/internal/path');
onAfterNavigateAway((event: AfterNavigateAwayData) => Promise<unknown>)

When initializing page IFrame, the workload app can register a callback to handle BeforeNavigateAway events. After passing all guard checks and confirming to leave the current page, the registered callback function will be invoked. In the callback function, the workload app can do something before actually leaving the current page, such as performing some clean up.

onBeforeNavigateAway((event: BeforeNavigateAwayData) => Promise<BeforeNavigateAwayResult>)

When initializing page IFrame, the workload app can register a callback to handle BeforeNavigateAway events. Before the workload app transitions away from the current view, the registered callback function will be invoked. In the callback function, the workload app can choose to either allow or deny the navigation. Note that even if the workload app allows the navigation, the destination page may still deny the navigation.

onNavigate((event: WorkloadNavigation) => void)

When initializing UI IFrame, the workload app must register a callback to handle Navigation events. When the route of the workload app is required to change, such as from /some/internal/path to /another/internal/path, the registered callback function will be invoked. In the callback function, the workload app needs to programmatically modify the route of the current UI IFrame and trigger the UI rendering accordingly.

Method Details

openBrowserTab(OpenBrowserTabParams)

Opens a new browser tab and navigates to the given route path

Example

// Open https://www.example.com in a new browser
await workloadClient.navigation.openBrowserTab( {path: 'https://www.example.com' });
function openBrowserTab(params: OpenBrowserTabParams): Promise<OpenBrowserTabResult>

Parameters

params
OpenBrowserTabParams

OpenBrowserTabParams contains:

  1. url
  2. queryParams (optional)

Returns

A Promise that resolves to 'true' when open browser tab succeeds, to 'false' when open browser tab fails, or is rejected on error.

Inherited Method Details

navigate<T>(T, (T extends "host" ? NavigationHostRoute : NavigationWorkloadRoute))

Navigates the target app to the given route path

Example

// Navigate to `/home` route of the host app
await workloadClient.navigation.navigate('host', '/home');

// Navigate to `/some/internal/path` route of the workload app
await workloadClient.navigation.navigate('workload', '/some/internal/path');
function navigate<T>(target: T, route: (T extends "host" ? NavigationHostRoute : NavigationWorkloadRoute)): Promise<NavigationResult>

Parameters

target

T

The target app to navigate.

  • host: the host app
  • workload: the workload app that calls the API
route

(T extends "host" ? NavigationHostRoute : NavigationWorkloadRoute)

The route path relative to the target app

Returns

Promise<NavigationResult>

A Promise that resolves to 'true' when navigation succeeds or no navigation, to 'false' when navigation fails, or is rejected on error.

Inherited From NavigationAPI$1.navigate

onAfterNavigateAway((event: AfterNavigateAwayData) => Promise<unknown>)

When initializing page IFrame, the workload app can register a callback to handle BeforeNavigateAway events. After passing all guard checks and confirming to leave the current page, the registered callback function will be invoked. In the callback function, the workload app can do something before actually leaving the current page, such as performing some clean up.

function onAfterNavigateAway(callback: (event: AfterNavigateAwayData) => Promise<unknown>)

Parameters

callback

(event: AfterNavigateAwayData) => Promise<unknown>

The callback function invoked when the AfterNavigateAway event is received by the page iframe

Inherited From NavigationAPI$1.onAfterNavigateAway

onBeforeNavigateAway((event: BeforeNavigateAwayData) => Promise<BeforeNavigateAwayResult>)

When initializing page IFrame, the workload app can register a callback to handle BeforeNavigateAway events. Before the workload app transitions away from the current view, the registered callback function will be invoked. In the callback function, the workload app can choose to either allow or deny the navigation. Note that even if the workload app allows the navigation, the destination page may still deny the navigation.

function onBeforeNavigateAway(callback: (event: BeforeNavigateAwayData) => Promise<BeforeNavigateAwayResult>)

Parameters

callback

(event: BeforeNavigateAwayData) => Promise<BeforeNavigateAwayResult>

The callback function invoked when the BeforeNavigateAway event is received by the page iframe

Inherited From NavigationAPI$1.onBeforeNavigateAway

onNavigate((event: WorkloadNavigation) => void)

When initializing UI IFrame, the workload app must register a callback to handle Navigation events. When the route of the workload app is required to change, such as from /some/internal/path to /another/internal/path, the registered callback function will be invoked. In the callback function, the workload app needs to programmatically modify the route of the current UI IFrame and trigger the UI rendering accordingly.

function onNavigate(callback: (event: WorkloadNavigation) => void)

Parameters

callback

(event: WorkloadNavigation) => void

The callback function invoked when a Navigation event is received by the UI iframe

Inherited From NavigationAPI$1.onNavigate