# vue-reactivestorage

> Reactive layer for interacting with localStorage from Vue.

Latest version **1.3.0** (published 2016-10-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install vue-reactivestorage
pnpm add vue-reactivestorage
yarn add vue-reactivestorage
bun add vue-reactivestorage
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2016-10-06 |
| First published | 2016-10-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 126 |
| Author | rop |
| Maintainers | rop |
| Keywords | vue, plugin, localstorage, vue2 |

## Links

- npm: https://www.npmjs.com/package/vue-reactivestorage
- Repository: https://github.com/ropbla9/vue-reactivestorage
- Homepage: https://github.com/ropbla9/vue-reactivestorage#readme
- Issues: https://github.com/ropbla9/vue-reactivestorage/issues
- npm.io page: https://npm.io/package/vue-reactivestorage

## Dependencies (1)

- [store](https://npm.io/package/store.md) ^1.3.20

## Recent versions

- 1.3.0 (latest) — 2016-10-06

## README

# vue-reactivestorage
Reactive layer for interacting with localStorage from Vue. Plugin for Vue 2.

### why

`window.localStorage` cannot be reactive if you use it directly with Vue, ex

<pre><code>
new Vue({
    data {
      localStorage: window.localStorage
    },
    template: " &lt;div&gt; {{localStorage.notes}}, {{localStorage.lang}} ... &lt;/div&gt; ",
    created: function() {
        this.localStorage.lang = "other value";
    }
})
</code></pre>

Code above will not react, even bind to view. So...

### how to use 

<pre><code>import reactiveStorage from "vue-reactivestorage";

Vue.use(reactiveStorage, [
    "notes", 
    "lang",
    "name",
    "foo"
]); 
</code></pre>

Define vars that will be stored and proxied by `Vue` (any other var in `window.localStorage` that is not on this array will not be proxied).

Now you can acess the namespace <code>localStorage</code> in Vue.

<pre><code>new Vue({
    template: " &lt;div&gt; {{localStorage.notes}}, {{localStorage.lang}} ... &lt;/div&gt; ",
    created: function() {
        this.localStorage.lang = "other value"; // will react on the view and on real localStorage.
    }
})
</code></pre>

---
_Source: https://npm.io/package/vue-reactivestorage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
