Skip to content

Commit 2752e29

Browse files
Implemented Navigate to root API.
Jira-ID: SDKCLI-14 Signed-off-by: suresh-gangumalla <[email protected]>
1 parent 44c7355 commit 2752e29

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Router/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,25 @@ const registerListener = () => {
484484
}
485485
})
486486
}
487+
488+
/**
489+
* Navigate to root hash
490+
*/
491+
const root = () => {
492+
const rootHash = getRootHash()
493+
if (isString(rootHash)) {
494+
navigate(rootHash)
495+
} else if (isFunction(rootHash)) {
496+
rootHash().then(res => {
497+
if (isObject(res)) {
498+
navigate(res.path, res.params)
499+
} else {
500+
navigate(res)
501+
}
502+
})
503+
}
504+
}
505+
487506
// export API
488507
export default {
489508
startRouter,
@@ -512,6 +531,7 @@ export default {
512531
App: RoutedApp,
513532
// keep backwards compatible
514533
focusPage: restoreFocus,
534+
root: root,
515535
/**
516536
* Deprecated api methods
517537
*/

0 commit comments

Comments
 (0)