Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.