New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vencakrecl/vuex-simple-cache

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vencakrecl/vuex-simple-cache

Simple cache for vuex action

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

vuex-simple-cache

NPM package version License Last test status

  • simple cache for vuex action

How to install

npm install @vencakrecl/vuex-simple-cache
yarn add @vencakrecl/vuex-simple-cache

How to use

import Vue from 'vue';
import Vuex, { Store } from 'vuex';
import VuexSimpleCache from '@vencakrecl/vuex-simple-cache';

Vue.use(Vuex);

const store = new Store({});

// create for every module
const cache = new VuexSimpleCache()

store.registerModule('test', {
  state: {
    items: [{ name: 'cachedData' }],
  },
  actions: {
    testAction: cache.cacheAction(
      'items',
      ({ commit }) => {
        // call API
        const data = [{ name: 'newData' }];

        return data;
      },
    ),
    testAction2: cache.cacheAction(
      'items',
      ({ commit }) => {
        // call API
        const data = [{ name: 'newData' }];

        commit('testMutation', data);

        return data;
      },
      120, // cache data for 120 seconds
      ({ commit }, data) => { // onCache callback
        commit('testMutation', data);
      }
    ),
  },
  mutation: {
    testMutation: (state, payload) => {
      state.items = payload
    }
  }
})

API - VuexSimpleCache.cacheAction

  • key - name of key from vuex state
  • action - standard vuex action
  • expiration - time in seconds (default 30s)
  • onCache - callback for cached data (default return cached data)

Keywords

FAQs

Package last updated on 06 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc