NavigationAPI interface

An interface representing navigation related APIs

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

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.

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

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

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