MCPcopy
hub / github.com/single-spa/single-spa / reroute

Function reroute

src/navigation/reroute.js:39–434  ·  view source on GitHub ↗
(
  pendingPromises = [],
  eventArguments,
  silentNavigation = false
)

Source from the content-addressed store, hash-verified

37}
38
39export function reroute(
40 pendingPromises = [],
41 eventArguments,
42 silentNavigation = false
43) {
44 if (appChangeUnderway) {
45 return new Promise((resolve, reject) => {
46 peopleWaitingOnAppChange.push({
47 resolve,
48 reject,
49 eventArguments,
50 });
51 });
52 }
53
54 let startTime, profilerKind;
55
56 if (__PROFILE__) {
57 startTime = performance.now();
58 if (silentNavigation) {
59 profilerKind = "silentNavigation";
60 } else if (eventArguments) {
61 profilerKind = "browserNavigation";
62 } else {
63 profilerKind = "triggerAppChange";
64 }
65 }
66
67 const { appsToUnload, appsToUnmount, appsToLoad, appsToMount } =
68 getAppChanges();
69 let appsThatChanged,
70 cancelPromises = [],
71 oldUrl = currentUrl,
72 newUrl = (currentUrl = window.location.href);
73
74 if (isStarted()) {
75 appChangeUnderway = true;
76 appsThatChanged = appsToUnload.concat(
77 appsToLoad,
78 appsToUnmount,
79 appsToMount
80 );
81 return performAppChanges();
82 } else {
83 appsThatChanged = appsToLoad;
84 return loadApps();
85 }
86
87 function cancelNavigation(val = true) {
88 const promise =
89 typeof val?.then === "function" ? val : Promise.resolve(val);
90 cancelPromises.push(
91 promise.catch((err) => {
92 console.warn(
93 Error(
94 formatErrorMessage(
95 42,
96 __DEV__ &&

Callers 7

startFunction · 0.90
registerApplicationFunction · 0.90
immediatelyUnloadAppFunction · 0.90
urlRerouteFunction · 0.90
triggerAppChangeFunction · 0.85
performAppChangesFunction · 0.85
finishUpAndReturnFunction · 0.85

Calls 4

getAppChangesFunction · 0.90
isStartedFunction · 0.90
performAppChangesFunction · 0.85
loadAppsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…