npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-reactive-storages

v1.0.14

Published

Plugin for vue and local/sessionStorage

Downloads

26

Readme

vue-reactive-storages

Installation

Using npm:

npm install --save vue-reactive-storages

Using cdn:

<script src="https://unpkg.com/vue-reactive-storages"></script>
<script>
const plugin = vueReactiveStoragesPlugin;
console.log(plugin);
console.log(plugin.version, plugin.ReactiveStorage, plugin.injectStorage);
</script>

Example

const reactivePlugin = require('vue-reactive-storages');
const Vue = require('vue');

const app = {
    router,
    store,
    render: h => h(App),
}

function listener(storage) {
    console.log(storage);
}

Vue.use(reactivePlugin, {
    app,
    preset: {
        test: '',
    },
    type: 'local',
    propName: '$RStore',
    listeners: [listener],
});

new Vue(app).$mount('#app');

Options

app - Required prop to create reactive storage and inject vuex

preset - Required prop to set scheme

type - Type of storage 'local' | 'session' Default local

storageName - Name of prop in local/sessionStorage Default $RStore

propName - Name of prop in Vue components and name of Vuex module (if exist) Default $RStore

listeners - Array with listeners on change data, once argument is storage Default []

Api

saveStorage

Arguments

noNeedEvent - Boolean true/false If true, events started in other tabs and run handlers Else if false, events started in all tabs(and in the same), and run handlers Default true

In most situations you don't need this function, but if you lose reactivity from Vue in this object, you can use it

Example

Vue.use(reactivePlugin, {
    app,
    preset: {
        test: '',
    },
    type: 'local',
    propName: '$RStore',
    listeners: [listener],
});
const store = app.$RStore;
store.saveStorage();

addChangeHandler

Function to add change-handler

Arguments

function with one arguments: reactiveStore - It's reactive store

Example

...
store.addChangeHandler((reactiveStore) => console.log(reactiveStore));
store.test = '1';
...

removeChangeHandler

Function ro remova change-handler, need the same function as in addChangeHandler

Arguments

function

Example

function log(reactiveStore) {
    console.log(reactiveStore)
}
store.addChangeHandler(log);
store.test = '1';
store.removeChangeHandler(log);
store.test = '2';

Separate api

reactiveStorage

Class for creating reactive storages

Arguments

preset - Required arg to set scheme

config

type - Type of storage 'local' | 'session' Default local

name - Name of prop in local/sessionStorage Default $RStore

listeners - Array with listeners on change data, once argument is storage Default []

Example

import { ReactiveStorage } from 'vue-reactive-storages';

const preset = {
    user: {
        token: '',
        id: '',
        login: '',
        role: '',
    },
};
const config = {
    type: 'local',
    name: '$RStore',
};

export default ReactiveStorage.create(preset, config);

injectStorage

function to inject storage in Vue

Arguments

Vue - Vue object

app - Required prop to create reactive storage and inject vuex

propName - Name of prop in Vue components and name of Vuex module (if exist) Default $RStore

storage - Object of injectable ReactiveStorage

Example

import Vue from 'vue';
import { injectStorage } from 'vue-reactive-storages';
import reactiveStore from './store';

const app = {
    router,
    store,
    render: h => h(App),
}

injectStorage(Vue, app, '$RStore', reactiveStore);

version

Version of packet

Example

import { version } from 'vue-reactive-storages';

console.log(version);