Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xerdi/meteor-local-storage
Meteor package for local storage with reactive var and dict.
https://github.com/xerdi/meteor-local-storage
local-storage meteor
Last synced: about 1 month ago
JSON representation
Meteor package for local storage with reactive var and dict.
- Host: GitHub
- URL: https://github.com/xerdi/meteor-local-storage
- Owner: Xerdi
- License: gpl-3.0
- Created: 2022-10-25T08:04:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-21T11:41:56.000Z (almost 2 years ago)
- Last Synced: 2024-11-11T14:44:41.654Z (3 months ago)
- Topics: local-storage, meteor
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Meteor Local Storage
Local Storage helpers for Meteor with `ReactiveVar` and `ReactiveDict`.
## Installation
Add the package to your project:
```shell
meteor add xerdi:local-storage
```## Usage
The package exports three classes which can be used similarly.
```ecmascript 6
import {LocalStorage, LocalVarStorage, LocalDictStorage} from 'xerdi:local-storage';const defaults = {
a: true,
b: 5,
c: 'text'
};export const mySettings = new LocalDictStorage('mySettings', defaults);
```## API
Both `LocalVarStorage` and `LocalDictStorage` extend from `LocalStorage`.
### LocalStorage
- `constructor` Takes a storage key and an object with default values.
- `get()` Gets the stored values.
- `set(keyOrObject, value)` Either gets an object for setting all values or a key and value to set.
- `unset(key)` Only works for `LocalDictStorage` and removes the given key from the dictionary.
- `setDefault()` Sets all values to their default value.
- `clear()` Wipes the stored data.