mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat: return if the pop on NavController was successful (#27404)
Issue number: Resolves #27403 --------- ## What is the current behavior? NavController.pop() returns `Promise<void>`. ## What is the new behavior? NavController.pop() returns `Promise<boolean>` propagating success/fail from underlying outlet. ## Does this introduce a breaking change? - [ ] Yes - [x] No ---------
This commit is contained in:
@@ -131,17 +131,21 @@ export class NavController {
|
||||
*
|
||||
* It recursively finds the top active `ion-router-outlet` and calls `pop()`.
|
||||
* This is the recommended way to go back when you are using `ion-router-outlet`.
|
||||
*
|
||||
* Resolves to `true` if it was able to pop.
|
||||
*/
|
||||
async pop(): Promise<void> {
|
||||
async pop(): Promise<boolean> {
|
||||
let outlet = this.topOutlet;
|
||||
|
||||
while (outlet) {
|
||||
if (await outlet.pop()) {
|
||||
break;
|
||||
return true;
|
||||
} else {
|
||||
outlet = outlet.parentOutlet;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user