feat(vue): extend useIonRouter hook for programmatic navigation with animation control (#23499)

resolves #23450
This commit is contained in:
Liam DeBeasi
2021-06-28 10:33:32 -04:00
committed by GitHub
parent 79e3a26499
commit fc9e1b4b36
10 changed files with 456 additions and 132 deletions

View File

@ -0,0 +1,15 @@
import { BackButtonEvent } from '@ionic/core/components';
type Handler = (processNextHandler: () => void) => Promise<any> | void | null;
export interface UseBackButtonResult {
unregister: () => void;
}
export const useBackButton = (priority: number, handler: Handler): UseBackButtonResult => {
const callback = (ev: BackButtonEvent) => ev.detail.register(priority, handler);
const unregister = () => document.removeEventListener('ionBackButton', callback);
document.addEventListener('ionBackButton', callback);
return { unregister };
}