jetlag2d
    Preparing search index...

    Class SessionValue<T>

    A key/value pair in the session storage that holds a value of type T.

    Make one as a constant, and use it wherever the value is needed:

    const RUN = new SessionValue("run", () => new Run());
    RUN.get().lives -= 1;
    

    For an object (or an array), get() gives back the stored object itself, so changing it changes what is stored. For a number, a string or a boolean, change it with set.

    Type Parameters

    • T
    Index
    • Make a pair in session storage

      Type Parameters

      • T

      Parameters

      • name: string

        What this value is called, for your own reference

      • initial: () => T

        A function that makes the value, the first time it is read

      Returns SessionValue<T>

    name: string

    What this value is called, for your own reference