forked from MapComplete/MapComplete
Performance improvements, add clock
This commit is contained in:
parent
c2b1f6643b
commit
efd7631837
21 changed files with 2947 additions and 105 deletions
30
UI/Base/LazyElement.ts
Normal file
30
UI/Base/LazyElement.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import {UIElement} from "../UIElement";
|
||||
|
||||
export default class LazyElement extends UIElement {
|
||||
|
||||
|
||||
private _content: UIElement = undefined;
|
||||
|
||||
public Activate: () => void;
|
||||
|
||||
constructor(content: (() => UIElement)) {
|
||||
super();
|
||||
this.dumbMode = false;
|
||||
const self = this;
|
||||
this.Activate = () => {
|
||||
if (this._content === undefined) {
|
||||
self._content = content();
|
||||
}
|
||||
self.Update();
|
||||
}
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
if (this._content === undefined) {
|
||||
return "Rendering...";
|
||||
}
|
||||
return this._content.InnerRender();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue