0.0.1 • Published 6 years ago

@copart/ops-local-storage v0.0.1

Weekly downloads
22
License
MIT
Repository
-
Last release
6 years ago
import { storage } from '@copart/yard-local-storage'

// NOTE: You SHOULD NOT be complex values in localStorage.
// localStorage is a simple key and string value mapping,
// not a database. If you find yourself storing complex
// values, consider flattening the value and storing each
// value separately.

// Set an item namespaced for your application.
storage.setItem('foo', 'foofoo')
storage.setItem('bar', false)
storage.setItem('baz', ['a', 'b', 'c'])
storage.getItem('baz')
// "<appName>.baz" -> ['a', 'b', 'c']

// Get localStorage data persisted by another application.
stprage.getStorage('dashboard')
stprage.getStorage('login')
stprage.getStorage('dispatchg2')

// Get nested value persisted by another application.
storage.getPath('login.userData.email')

// Built in helper to automatically check necessary authentication values.
storage.checkAuth()

// For storing temporary data that will not persist in the case of
// refresh, new tab, etc. (Does not actually go into localStorage.)
storage.setTempItem('cool', true)

// Allows you to retrieve the config stored by ConfigManager.
storage.getConfig()

// Provides all localStorage values that belong to your app's namespace.
storage.inspect()

// When process.env.NODE_ENV === 'development', storage can be accessed
// on the global window object as window.yardLocalStorage. This is meant
// to be used for debugging ONLY and will NOT work in production.