Function localstorage

  • A writeable store that autosyncs with localstorage It can also be used to sync state between multiple tabs/windows

    Type Parameters

    • T

    Parameters

    • key: string
    • fallback: T

    Returns {
        set: ((newValue) => void);
        subscribe: ((this, run, invalidate?) => Unsubscriber);
        update: ((newValueFn) => void);
    }

    • set: ((newValue) => void)

      Set a new value into the store, this will also affect all other svocal stores using the same key and will write to the localstorage

      Param: newValue

      The new value to set

        • (newValue): void
        • Set a new value into the store, this will also affect all other svocal stores using the same key and will write to the localstorage

          Parameters

          • newValue: T

            The new value to set

          Returns void

    • subscribe: ((this, run, invalidate?) => Unsubscriber)
        • (this, run, invalidate?): Unsubscriber
        • Subscribe on value changes.

          Parameters

          • this: void
          • run: Subscriber<T>

            subscription callback

          • Optional invalidate: Invalidator<T>

            cleanup callback

          Returns Unsubscriber

    • update: ((newValueFn) => void)

      Update the store using a function It will affect other stores with the same key and write to the localstorage

      Param: newValueFn

      A function which return value will be the new value

        • (newValueFn): void
        • Update the store using a function It will affect other stores with the same key and write to the localstorage

          Parameters

          • newValueFn: ((oldVal) => T)

            A function which return value will be the new value

              • (oldVal): T
              • Parameters

                • oldVal: T

                Returns T

          Returns void

Generated using TypeDoc