NavigationClient class
Constructors
| Navigation |
Methods
| navigate<T>(T, (T extends "host" ? Navigation |
Navigates the target app to the given route path Example
|
| on |
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. |
| on |
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. |
| on |
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 |
| open |
Opens a new browser tab and navigates to the given route path Example
|
Constructor Details
NavigationClient(WorkloadClient)
new NavigationClient(workloadClientCommon: WorkloadClient)
Parameters
- workloadClientCommon
-
WorkloadClient
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 appworkload: 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((leaveEndData: 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: (leaveEndData: AfterNavigateAwayData) => Promise<unknown>)
Parameters
- callback
-
(leaveEndData: AfterNavigateAwayData) => Promise<unknown>
The callback function invoked when the AfterNavigateAway event is received by the page iframe
onBeforeNavigateAway((leaveData: 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: (leaveData: BeforeNavigateAwayData) => Promise<BeforeNavigateAwayResult>)
Parameters
- callback
-
(leaveData: BeforeNavigateAwayData) => Promise<BeforeNavigateAwayResult>
The callback function invoked when the BeforeNavigateAway event is received by the page iframe
onNavigate((navigation: 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: (navigation: WorkloadNavigation) => void)
Parameters
- callback
-
(navigation: WorkloadNavigation) => void
The callback function invoked when a Navigation event is received by the UI iframe
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
Returns
Promise<OpenBrowserTabResult>
A Promise that resolves to 'true' when open browser tab succeeds, to 'false' when open browser tab fails, or is rejected on error.