single-spa
Advanced tools
Comparing version 2.0.12 to 2.1.0
@@ -20,3 +20,5 @@ # Child applications (chapps) | ||
During the course of a single-spa app, child applications are loaded, initialized, mounted, and remounted. | ||
single-spa provides hooks into these lifecycle events via lifecycle functions. | ||
single-spa provides hooks into the latter three lifecycle events via lifecycle functions. In order to | ||
hook into the `load` lifecycle, simply put code into the application that is run without a function being | ||
called. | ||
@@ -32,2 +34,4 @@ A lifecycle function is a function or array of functions that single-spa will call on a child application. | ||
one-after-the-other, waiting for the resolution of one function's promise before calling the next. | ||
- If single-spa is [paused](/docs/single-spa-api.md#pause), no lifecycle functions will be called on any | ||
child applications. | ||
@@ -34,0 +38,0 @@ ### Lifecycle middleware |
@@ -48,2 +48,9 @@ # single-spa API | ||
## pause | ||
`pause()`: when single-spa is paused, all child application lifecycles (except for importing the child app's source code) | ||
will not be called until unpause is called. | ||
## unpause | ||
`unpause()` all child application lifecycles. | ||
## setBootstrapMaxTime | ||
@@ -50,0 +57,0 @@ `setBootstrapMaxTime(millis, dieOnTimeout = false)` takes in a number of milliseconds and a boolean dieOnTimeout |
@@ -21,2 +21,4 @@ 'use strict'; | ||
exports.triggerAppChange = triggerAppChange; | ||
exports.pause = pause; | ||
exports.unpause = unpause; | ||
exports.navigateToUrl = navigateToUrl; | ||
@@ -52,5 +54,7 @@ | ||
appChangeUnderway = void 0, | ||
capturedEventListeners = void 0; | ||
capturedEventListeners = void 0, | ||
isPaused = void 0; | ||
function reset() { | ||
isPaused = false; | ||
childApps = []; | ||
@@ -207,2 +211,9 @@ | ||
triggerAppChange(); | ||
if (activeWhen(window.location)) { | ||
// Start loading the child application as soon as possible, especially if paused. | ||
Loader.import(appLocation).catch(function (ex) { | ||
throw ex; | ||
}); | ||
} | ||
} | ||
@@ -214,2 +225,11 @@ | ||
function pause() { | ||
isPaused = true; | ||
} | ||
function unpause() { | ||
isPaused = false; | ||
performAppChanges(); | ||
} | ||
function navigateToUrl(obj) { | ||
@@ -260,2 +280,6 @@ var url = void 0; | ||
if (isPaused) { | ||
return Promise.resolve(getMountedApps()); | ||
} | ||
appChangeUnderway = true; | ||
@@ -262,0 +286,0 @@ |
{ | ||
"name": "single-spa", | ||
"version": "2.0.12", | ||
"version": "2.1.0", | ||
"description": "Multiple applications, one page", | ||
@@ -11,3 +11,3 @@ "main": "lib/single-spa.js", | ||
"test": "jasmine", | ||
"build:canopy": "npm run build && rm -rf ../spalpatine/jspm_packages/npm/single-spa@2.0.11 && rsync -av . ../spalpatine/jspm_packages/npm/single-spa@2.0.11 --exclude node_modules --exclude .git --exclude --spec --exclude examples && cd ../spalpatine && npm run build-common-deps && cd ../single-spa" | ||
"build:canopy": "npm run build && rm -rf ../spalpatine/jspm_packages/npm/single-spa@2.1.0 && rsync -av . ../spalpatine/jspm_packages/npm/single-spa@2.1.0 --exclude node_modules --exclude .git --exclude --spec --exclude examples && cd ../spalpatine && npm run build-common-deps && cd ../single-spa" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": "https://github.com/CanopyTax/single-spa", |
@@ -23,5 +23,6 @@ import { handleChildAppError } from './single-spa-child-app-error.js'; | ||
// Things that need to be reset with the init function; | ||
let Loader, childApps, globalTimeoutConfig, peopleWaitingOnAppChange, appChangeUnderway, capturedEventListeners; | ||
let Loader, childApps, globalTimeoutConfig, peopleWaitingOnAppChange, appChangeUnderway, capturedEventListeners, isPaused; | ||
export function reset() { | ||
isPaused = false; | ||
childApps = []; | ||
@@ -169,2 +170,9 @@ | ||
triggerAppChange(); | ||
if (activeWhen(window.location)) { | ||
// Start loading the child application as soon as possible, especially if paused. | ||
Loader | ||
.import(appLocation) | ||
.catch(ex => {throw ex}); | ||
} | ||
} | ||
@@ -176,2 +184,11 @@ | ||
export function pause() { | ||
isPaused = true; | ||
} | ||
export function unpause() { | ||
isPaused = false; | ||
performAppChanges(); | ||
} | ||
export function navigateToUrl(obj) { | ||
@@ -219,2 +236,6 @@ let url; | ||
if (isPaused) { | ||
return Promise.resolve(getMountedApps()); | ||
} | ||
appChangeUnderway = true; | ||
@@ -221,0 +242,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60135
1071