@phoenix-cg/storage

1.0.4 • Public • Published

Storage

localStorage is a property that allows JavaScript sites and apps to save key-value pairs in a web browser with no expiration date. sessionStorage allows you to store data in the browser depending on the system memory and the data stored in the browser until the browser is closed. Storage is a class to add or remove item from local or session storage.

Installation

  npm i @phoenix-cg/storage

Methods

Method Description
setItem(key, value) Add key and value to localStorage
getItem(key) This is how you get items from localStorage
removeItem(key) Remove an item from localStorage

Usage

  import { storageLocal, storageSession } from '@phoenix-cg/storage'

  ...

  methods: {
    clientMounted () {
      const bannerShown = this.storageLocal.getItem('banner-shown')
      
      if (showBanner) {
        this.showBanner()
      }
      this.storageLocal.setItem('banner-shown', 1)
    },

    ...

    hideBanner () {
      this.popupResetTimeoutId = setTimeout(() => {
        this.storageLocal.getItem('banner-shown')
      }, 100)
    },
    resetBanenr () {
      this.storageLocal.removeItem('banner-shown')
    }
  }

Readme

Keywords

none

Package Sidebar

Install

npm i @phoenix-cg/storage

Weekly Downloads

6

Version

1.0.4

License

ISC

Unpacked Size

2.92 kB

Total Files

7

Last publish

Collaborators

  • phoenix-cg-dev