Lime Web Components API Documentation - v7.4.0
    Preparing search index...

    Type Alias Retry

    Retry: () => void

    Function to retry blocked navigation

    Provided by Transition to resume navigation after it was blocked by a Blocker. Call this after user confirmation or other conditions are met.

    Type Declaration

      • (): void
      • Returns void

    import {
    Blocker,
    PlatformServiceName,
    Transition,
    } from '@limetech/lime-web-components';

    const navigator = platform.get(PlatformServiceName.Navigator);

    let hasUnsavedChanges = false;

    const blocker: Blocker = (transition: Transition) => {
    if (!hasUnsavedChanges) {
    return false;
    }

    void confirmNavigation(transition);

    // Block for now, `retry()` resumes the navigation if the user confirms
    return true;
    };

    async function confirmNavigation(transition: Transition) {
    const shouldNavigate = await showConfirmDialog();

    if (!shouldNavigate) {
    return;
    }

    hasUnsavedChanges = false;
    navigator.removeBlocker(blocker);
    transition.retry();
    }

    // Stands in for the dialog the component would open
    async function showConfirmDialog(): Promise<boolean> {
    return confirm('You have unsaved changes. Leave anyway?');
    }

    navigator.addBlocker(blocker);