Socket
Socket
Sign inDemoInstall

reactive-localstorage

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reactive-localstorage

A reactive localStorage with no dependency


Version published
Weekly downloads
866
decreased by-7.08%
Maintainers
1
Install size
55.2 kB
Created
Weekly downloads
 

Changelog

Source

[1.0.1] - 2020-07-17

Fixed

  • failed to dispatch storage event to localStorage and sessionStorage

Readme

Source

reactive-localstorage

A reactive localStorage with no dependency

Install
yarn add reactive-localstorage
npm i -S reactive-localstorage
Features
  • inject window.localStorage / window.sessionStorage
  • Emit changes from same window
  • Emit external changes
Usage

Changes from reactive-localstorage or other pages will be emitted as events

import localStorage, { localStorage } from 'reactive-localstorage';

localStorage.on('change', (key, value) => {
  console.log(`key ${key} changed to ${value}`);
});

localStorage.setItem('foo', 'bar');

// print key foo changed to bar

It also works with window.localStorage

window.localStorage.setItem('foo', 'alice');

// print key foo changed to alice

You can also trigger changes manually, especially when you have other sources that manage localStorage.

localStorage.feed('foo', 'bob');

// print key foo changed to bob

SessionStorage is also supported

import { sessionStorage } from 'reactive-localstorage';

sessionStorage.on('change', (key, value) => {
  console.log(`key ${key} changed to ${value}`);
});

sessionStorage.setItem('foo', 'bar');

// print key foo changed to bar
  • mobx-localstorage
  • rx-localstorage

Keywords

FAQs

Last updated on 17 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc