A callback that is called when a history navigation is intended.
A transaction that describes the intended navigation.
true or undefined if the transaction should be blocked until HistoryTransaction.proceed is called, or false if the transaction shouldn't be blocked.
true
undefined
false
const blocker: HistoryBlocker = transaction => { return hasUnsavedChanges && !confirm('Discard unsaved changes?')}; Copy
const blocker: HistoryBlocker = transaction => { return hasUnsavedChanges && !confirm('Discard unsaved changes?')};
const blocker: HistoryBlocker = transaction => { if (!hasUnsavedChanges) { // No unsaved changes, proceed with navigation transaction.proceed(); return; } if (!confirm('Discard unsaved changes?')) { // User decided to keep unsaved changes transaction.cancel(); }}; Copy
const blocker: HistoryBlocker = transaction => { if (!hasUnsavedChanges) { // No unsaved changes, proceed with navigation transaction.proceed(); return; } if (!confirm('Discard unsaved changes?')) { // User decided to keep unsaved changes transaction.cancel(); }};
A callback that is called when a history navigation is intended.