mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
refactor: share search history
This commit is contained in:
@@ -74,3 +74,21 @@ declare function cancelIdleCallback(handle: number): void;
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
// TODO: handle error
|
||||
export class LazyValue<T> {
|
||||
private _value: T | undefined
|
||||
private _didRun = false
|
||||
|
||||
constructor(
|
||||
private executor: () => T,
|
||||
) {}
|
||||
|
||||
get value(): T {
|
||||
if (!this._didRun) {
|
||||
this._value = this.executor()
|
||||
this._didRun = true
|
||||
}
|
||||
return this._value!
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user