fix(core): update

This commit is contained in:
Philipp Kunz 2020-12-08 22:29:19 +00:00
parent 11282daa38
commit 3278ef7425

View File

@ -5,6 +5,7 @@ import { TagLevel } from './websetup.classes.taglevel';
export interface IWebSetupConstructorOptions { export interface IWebSetupConstructorOptions {
metaObject: interfaces.IMetaObject; metaObject: interfaces.IMetaObject;
smartssrWaitForReadySignal?: boolean;
} }
/** /**
@ -13,12 +14,21 @@ export interface IWebSetupConstructorOptions {
export class WebSetup { export class WebSetup {
public tagManager: TagManager = new TagManager(); public tagManager: TagManager = new TagManager();
public options: IWebSetupConstructorOptions; public options: IWebSetupConstructorOptions;
// private deferreds
private readyDeferred = plugins.smartpromise.defer(); private readyDeferred = plugins.smartpromise.defer();
private readyForSmartssrDeferred = plugins.smartpromise.defer();
// public promises
public readyPromise = this.readyDeferred.promise; public readyPromise = this.readyDeferred.promise;
public readyForSmartssrPromise = this.readyForSmartssrDeferred.promise;
constructor(optionsArg: IWebSetupConstructorOptions) { constructor(optionsArg: IWebSetupConstructorOptions) {
this.options = optionsArg; this.options = optionsArg;
this.setup().then(() => { this.setup().then(() => {
this.readyDeferred.resolve(); this.readyDeferred.resolve();
if (!this.options.smartssrWaitForReadySignal) {
this.readyForSmartssrDeferred.resolve();
}
}); });
} }
@ -49,4 +59,14 @@ export class WebSetup {
} }
public flashTitle(flashTextArg: string) {} public flashTitle(flashTextArg: string) {}
/**
* informs smartssr that the page is ready to be rendered
*/
public informReadyForSmartssr() {
if (!this.options.smartssrWaitForReadySignal) {
console.error(`You have not indicated that you inform smartssr by a dedicated signal! Please consider doing so!`);
}
this.readyForSmartssrDeferred.resolve();
}
} }