How to use the boring-router.isHistoryEntryEqual function in boring-router

To help you get started, we’ve selected a few boring-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github makeflow / boring-router / packages / boring-router-react / src / library / browser-history.ts View on Github external
let trackedActiveIndex = getActiveHistoryEntryIndex(tracked);

    let minLength = Math.min(expectedEntries.length, trackedEntries.length);

    let firstMismatchedIndex = 0;

    for (
      firstMismatchedIndex;
      firstMismatchedIndex < minLength;
      firstMismatchedIndex++
    ) {
      let expectedEntry = expectedEntries[firstMismatchedIndex];
      let trackedEntry = trackedEntries[firstMismatchedIndex];

      if (!isHistoryEntryEqual(expectedEntry, trackedEntry)) {
        break;
      }
    }

    if (
      firstMismatchedIndex > lastExpectedIndex &&
      (lastExpectedIndex === lastTrackedIndex || lastExpectedIndex === 0)
    ) {
      // 1. Exactly identical.
      // 2. Not exactly identical but there's not much that can be done:
      //    ```
      //    expected  a
      //    tracked   a -> b
      //                   ^ mismatch
      //    ```
      //    In this case we cannot remove the extra entries.

boring-router

A type-safe MobX router with parallel routing support.

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis

Similar packages