mapcomplete/UI/Base/Lazy.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
424 B
TypeScript
Raw Normal View History

import BaseUIElement from "../BaseUIElement"
2021-11-07 16:34:51 +01:00
export default class Lazy extends BaseUIElement {
private readonly _f: () => BaseUIElement
2021-11-07 16:34:51 +01:00
constructor(f: () => BaseUIElement) {
super()
this._f = f
}
2021-11-07 16:34:51 +01:00
protected InnerConstructElement(): HTMLElement {
// The caching of the BaseUIElement will guarantee that _f will only be called once
return this._f().ConstructElement()
}
}