forked from MapComplete/MapComplete
Make question generation laze, huge performance boost
This commit is contained in:
parent
8b870474d7
commit
4c2beb5334
2 changed files with 19 additions and 2 deletions
16
UI/Base/Lazy.ts
Normal file
16
UI/Base/Lazy.ts
Normal 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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue