.. role:: clio-readonly
   :class: clio-flag clio-flag-readonly

.. role:: clio-static
   :class: clio-flag clio-flag-static


####
Lazy
####

.. js: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 to ``get()``\ .
   
   
   
   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 6
   
   
   
   Note: Unlike ``LazyObject<T>``\ , this can have any type ``T``\ .
   
   
   Index
   =====
   
   .. rubric:: Properties
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:data:`~wv.Util.Lazy.__Lazy`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~static wv.Util.Lazy.create`
   * :js:meth:`~wv.Util.Lazy.get`
   
   



.. rst-class:: kind-group kind-properties

.. rubric:: Properties
   :class: kind-group-title


.. js:data:: wv.Util.Lazy.__Lazy

      .. rst-class:: clio-flags
      
         :clio-readonly:`readonly`
      
      .. rst-class:: sig-pretty-signature
      
         | __Lazy: *PhantomMember*
      



.. rst-class:: kind-group kind-methods

.. rubric:: Methods
   :class: kind-group-title


.. js:method:: static wv.Util.Lazy.create

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | create(**value**\ : () => T): :js:class:`Lazy <wv.Util.Lazy>`\ <T>
      
      Creates a new lazy value, which is the result of the supplied function once the lazy value is forced.
      
      **Parameters**
      
      
         **value**\ : () => T
      
      
      **Returns**\ : :js:class:`Lazy <wv.Util.Lazy>`\ <T>
      



.. js:method:: wv.Util.Lazy.get

      .. rst-class:: sig-pretty-signature
      
         | get(): T
      
      Forces the lazy value given at construction and returns it.
      
      **Returns**\ : T
      




