Lazy
Lazy(f)
Creates a lazy value. The computation won't happen until the first access.
A lazy
type exposes a get
method that'll return the result from the computation.
import { Lazy } from "@swan-io/boxed";
const lazy = Lazy(() => {
return myComputation();
});
lazy.get()
Computes the value once and returns it.
lazy.get(); // value is computed and return here