Function createCachedValue

  • Create and return a readonly ICachedValue instance that is populated with the provided value. This is useful when you want to cache a previously fetched value and return it without having to re-fetch it again. This is a lightweight version of getLazy which does not support any expiration or invalidation, it also will not honor the setBypassLazyCache setting and will always return the provided value.

    Type Parameters

    • T

    Parameters

    • value: T

    Returns ICachedValue<T>

    A new ICachedValue instance which wraps the provided value

    Since

    0.10.5

    Typeparam

    T - The type of the value to be cached

    Example

    let cachedValue = createCachedValue("some value");
    // cachedValue.v === "some value"

    JSON.stringify(cachedValue) === '{"v":"some value"}';