Sfoglia il codice sorgente

Add skipRouting option to router navigation.

Brian E. Granger 4 anni fa
parent
commit
8ba2828aca
2 ha cambiato i file con 13 aggiunte e 5 eliminazioni
  1. 7 5
      packages/application/src/router.ts
  2. 6 0
      packages/application/src/tokens.ts

+ 7 - 5
packages/application/src/router.ts

@@ -88,11 +88,13 @@ export class Router implements IRouter {
       return this.reload();
     }
 
-    // Because a `route()` call may still be in the stack after having received
-    // a `stop` token, wait for the next stack frame before calling `route()`.
-    requestAnimationFrame(() => {
-      void this.route();
-    });
+    if (!options.skipRouting) {
+      // Because a `route()` call may still be in the stack after having received
+      // a `stop` token, wait for the next stack frame before calling `route()`.
+      requestAnimationFrame(() => {
+        void this.route();
+      });
+    }
   }
 
   /**

+ 6 - 0
packages/application/src/tokens.ts

@@ -144,6 +144,12 @@ export namespace IRouter {
      * history API change.
      */
     hard?: boolean;
+
+    /**
+     * Should the routing stage be skipped when navigating? This will simply rewrite the URL
+     * and push the new state to the history API, no routing commands will be triggered.
+     */
+    skipRouting?: boolean;
   }
 
   /**