()
| 311 | } |
| 312 | |
| 313 | function finishUpAndReturn() { |
| 314 | const returnValue = getMountedApps(); |
| 315 | pendingPromises.forEach((promise) => promise.resolve(returnValue)); |
| 316 | |
| 317 | try { |
| 318 | const appChangeEventName = |
| 319 | appsThatChanged.length === 0 ? "no-app-change" : "app-change"; |
| 320 | fireSingleSpaEvent(appChangeEventName, getCustomEventDetail()); |
| 321 | fireSingleSpaEvent("routing-event", getCustomEventDetail()); |
| 322 | } catch (err) { |
| 323 | /* We use a setTimeout because if someone else's event handler throws an error, single-spa |
| 324 | * needs to carry on. If a listener to the event throws an error, it's their own fault, not |
| 325 | * single-spa's. |
| 326 | */ |
| 327 | setTimeout(() => { |
| 328 | throw err; |
| 329 | }); |
| 330 | } |
| 331 | |
| 332 | /* Setting this allows for subsequent calls to reroute() to actually perform |
| 333 | * a reroute instead of just getting queued behind the current reroute call. |
| 334 | * We want to do this after the mounting/unmounting is done but before we |
| 335 | * resolve the promise for the `reroute` function. |
| 336 | */ |
| 337 | appChangeUnderway = false; |
| 338 | |
| 339 | if (peopleWaitingOnAppChange.length > 0) { |
| 340 | /* While we were rerouting, someone else triggered another reroute that got queued. |
| 341 | * So we need reroute again. |
| 342 | */ |
| 343 | const nextPendingPromises = peopleWaitingOnAppChange; |
| 344 | peopleWaitingOnAppChange = []; |
| 345 | reroute(nextPendingPromises); |
| 346 | } |
| 347 | |
| 348 | return returnValue; |
| 349 | } |
| 350 | |
| 351 | /* We need to call all event listeners that have been delayed because they were |
| 352 | * waiting on single-spa. This includes haschange and popstate events for both |
nothing calls this directly
no test coverage detected
searching dependent graphs…