import { NavigationBlocked } from "../errors" ; import { IJetApp , IJetURL , IJetView } from "../interfaces" ; export function UnloadGuard ( app , view , config ) { view . on ( app , `app:guard` , function ( _$url , point , promise ) { if ( point === view || point . contains ( view ) ) { const res = config ( ) ; if ( res === false ) { promise . confirm = Promise . reject ( new NavigationBlocked ( ) ) ; } else { promise . confirm = promise . confirm . then ( ( ) => res ) ; } } } ) ; }