Make question generation laze, huge performance boost

This commit is contained in:
Pieter Vander Vennet 2021-10-01 03:14:36 +02:00
parent 8b870474d7
commit 4c2beb5334
2 changed files with 19 additions and 2 deletions

16
UI/Base/Lazy.ts Normal file
View file

@ -0,0 +1,16 @@
import BaseUIElement from "../BaseUIElement";
export default class Lazy extends BaseUIElement{
private readonly _f: () => BaseUIElement;
constructor(f: () => BaseUIElement) {
super();
this._f = f;
}
protected InnerConstructElement(): HTMLElement {
// The caching of the BaseUIElement will guarantee that _f will only be called once
return this._f().ConstructElement();
}
}