Performace improvement with Promise.resolve

pull/8773/head
Aleix Suau 4 years ago
parent 83c667aa2c
commit 78cf2a2a86
  1. 16
      frontend/src/app/globals/dynamic-bootstrapper.ts

@ -82,17 +82,11 @@ export class DynamicBootstrapper {
* @param {OptionalBootstrapDefinition[]|undefined} definitions An optional set of components to bootstrap
*/
public static bootstrapOptionalEmbeddable(appRef:ApplicationRef, element:HTMLElement, definitions = this.optionalBoostrapComponents) {
// Avoid bootstrapping the embedded components while the app
// is running the Change Detection ("ApplicationRef.tick
// is called recursively" error)
appRef
.isStable
.pipe(
filter(isStable => isStable),
take(1),
)
.toPromise()
.then(() => this.performBootstrap(appRef, element, true, definitions));
// Delay the execution to avoid bootstrapping the embedded components while
// the app is running the Change Detection ("ApplicationRef.tick is called recursively"
// error) caused because of bootstrapOptionalEmbeddable and bootstrapOptionalDocument
// calling this.performBootstrap at the same time
Promise.resolve().then(() => this.performBootstrap(appRef, element, true, definitions));
}
/**

Loading…
Cancel
Save