Lazy
-
class
wv.Util.Lazy() This is used to delay the evaluation of a value.
Evaluation is completely deferred until
get()is called. Evaluation happens no more than once and the obtained value is cached for later calls toget().Example:
const x = Lazy.create(() => { console.log("evaluating (x)") return 5; }); console.log("created (x)"); console.log(`(x) is ${x.get()}`); console.log(`(x+1) is ${x.get()+1}`); // *** Console Output *** // created (x) // evaluating (x) // (x) is 5 // (x+1) is 6Note: Unlike
LazyObject<T>, this can have any typeT.
Properties
-
wv.Util.Lazy.__Lazy readonly
__Lazy: PhantomMember
Methods
-
static wv.Util.Lazy.create() static
create(value: () => T):Lazy<T>Creates a new lazy value, which is the result of the supplied function once the lazy value is forced.
Parameters
value: () => TReturns:
Lazy<T>
-
wv.Util.Lazy.get() - get(): T
Forces the lazy value given at construction and returns it.
Returns: T