Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "local-storage-events"

Index

Classes

Interfaces

Functions

Functions

deleteFromStorage

  • deleteFromStorage(key: string): void
  • Use this function to delete a value from localStorage.

    example
    const user = { name: 'John', email: 'John@fakemail.com' };
    
    // Add a user to your localStorage
    writeStorage('user', JSON.stringify(user));
    
    // This will also trigger an update to the state of your component
    deleteFromStorage('user');
    export

    Parameters

    • key: string

      The key of the item you wish to delete from localStorage.

    Returns void

writeStorage

  • writeStorage<TValue>(key: string, value: TValue): void
  • Use this instead of directly using localStorage.setItem in order to correctly send events within the same window.

    example
    writeStorage('hello', JSON.stringify({ name: 'world' }));
    const { name } = JSON.parse(localStorage.getItem('hello'));
    export

    Type parameters

    • TValue

    Parameters

    • key: string

      The key to write to in the localStorage.

    • value: TValue

      The value to write to in the localStorage.

    Returns void

Generated using TypeDoc