vuex-cache
Advanced tools
Comparing version 0.1.0 to 0.3.0
13
index.js
@@ -14,3 +14,3 @@ 'use strict'; | ||
store.clearCache = function () { | ||
store.removeCache = function () { | ||
var type = arguments.length <= 0 ? undefined : arguments[0]; | ||
@@ -23,4 +23,15 @@ if (type in cache) { | ||
}; | ||
store.hasCache = function (key) { | ||
return key in cache; | ||
}; | ||
store.clearCache = function () { | ||
for (var key in cache) { | ||
delete cache[key]; | ||
} | ||
return true; | ||
}; | ||
}); | ||
module.exports = index; |
{ | ||
"name": "vuex-cache", | ||
"version": "0.1.0", | ||
"version": "0.3.0", | ||
"description": "cache vuex action", | ||
@@ -12,5 +12,6 @@ "main": "index.js", | ||
"test": "NODE_ENV=test mocha --opts test/mocha.opts test", | ||
"cover": "NODE_ENV=test istanbul cover $(npm bin)/_mocha test", | ||
"lint": "eslint src/index.js", | ||
"build": "NODE_ENV=production rollup -c", | ||
"prepublish": "npm run build" | ||
"prepublish": "npm run lint && npm run build" | ||
}, | ||
@@ -37,2 +38,3 @@ "keywords": [ | ||
"expect": "^1.20.2", | ||
"istanbul": "1.0.0-alpha.2", | ||
"mocha": "^3.2.0", | ||
@@ -39,0 +41,0 @@ "rollup": "^0.41.6", |
@@ -5,4 +5,2 @@ # vuex cache action | ||
Inspired by reselect | ||
When vuex action fetch some data by request remote api, vuex-cache can store the action result, when next time the same action runs, it will not make a new request and just return the cached result. | ||
@@ -48,4 +46,14 @@ | ||
``` | ||
store.clearCache(ACTION_NAME) | ||
store.removeCache(ACTION_NAME) | ||
``` | ||
clear cached action, **not** clear the data in store. when call cacheDispatch with same type, the request in that action will run again. | ||
clear cached action, will **not** clear the data in store. when call cacheDispatch with same type, the request in that action will run again. | ||
``` | ||
store.hasCache(ACTION_NAME) | ||
``` | ||
return bool if ACTION\_NAME has been cached | ||
``` | ||
store.clearCache | ||
``` | ||
clear all cached keys |
3239
4
30
58
17