vuex-cache
Advanced tools
Comparing version 0.3.0 to 0.3.1
11
index.js
@@ -5,4 +5,4 @@ 'use strict'; | ||
var cache = Object.create(null); | ||
store.cacheDispatch = function () { | ||
var type = arguments.length <= 0 ? undefined : arguments[0]; | ||
store.cacheDispatch = function cacheDispatch() { | ||
var type = arguments[0]; | ||
if (type in cache) { | ||
@@ -15,6 +15,5 @@ return cache[type]; | ||
store.removeCache = function () { | ||
var type = arguments.length <= 0 ? undefined : arguments[0]; | ||
if (type in cache) { | ||
delete cache[type]; | ||
store.removeCache = function (actionName) { | ||
if (actionName in cache) { | ||
delete cache[actionName]; | ||
return true; | ||
@@ -21,0 +20,0 @@ } |
{ | ||
"name": "vuex-cache", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "cache vuex action", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"build": "NODE_ENV=production rollup -c", | ||
"prepublish": "npm run lint && npm run build" | ||
"prepublish": "npm run lint && npm run cover && npm run build" | ||
}, | ||
@@ -18,0 +18,0 @@ "keywords": [ |
@@ -8,3 +8,3 @@ # vuex cache action | ||
## install | ||
``` | ||
```bash | ||
npm install vuex-cache | ||
@@ -15,3 +15,4 @@ ``` | ||
``` | ||
```javascript | ||
import Vuex from 'vuex' | ||
import vuexCache from 'vuex-cache' | ||
@@ -39,3 +40,3 @@ const store = new Vuex.Store({ | ||
``` | ||
```javascript | ||
store.cacheDispatch(ACTION_NAME) | ||
@@ -47,8 +48,8 @@ ``` | ||
``` | ||
```javascript | ||
store.removeCache(ACTION_NAME) | ||
``` | ||
clear cached action, will **not** clear the data in store. when call cacheDispatch with same type, the request in that action will run again. | ||
remove cached action, will **not** remove the data in store. when call cacheDispatch with same type, the request in that action will run again. | ||
``` | ||
```javascript | ||
store.hasCache(ACTION_NAME) | ||
@@ -58,5 +59,5 @@ ``` | ||
```javascript | ||
store.clearCache() | ||
``` | ||
store.clearCache | ||
``` | ||
clear all cached keys |
3272
59
29