Reactive Local Storage Library
A JavaScript library for reactive interactions with local storage, making it easier to synchronize local storage data with your application's state.
Features
- Reactive Bindings: Automatically updates the application state when local storage data changes.
- Simplified API: Easy get and set operations with local storage, including automatic JSON parsing and stringification.
- Subscription Model: Subscribe to changes in specific local storage keys.
Installation
Copy the index.js
file into your project, or include it in your build process.
Usage
import reactiveLocalStorage from './path/to/reactive-local-storage-library';
reactiveLocalStorage.subscribe('myKey', newValue => {
console.log('Value for myKey changed:', newValue);
});
reactiveLocalStorage.set('myKey', { some: 'data' });
const currentValue = reactiveLocalStorage.get('myKey');
console.log(currentValue);
reactiveLocalStorage.unsubscribe('myKey', callback);