瀏覽代碼

Add skipRouting option to router navigation.

Brian E. Granger 4 年之前
父節點
當前提交
8ba2828aca
共有 2 個文件被更改,包括 13 次插入5 次删除
  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;
   }
 
   /**