-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1db59b0
commit 088cdcc
Showing
6 changed files
with
127 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,50 @@ | ||
# vuex-simple-cache | ||
|
||
[![NPM package version][npm]](https://www.npmjs.com/package/@vencakrecl/vuex-simple-cache) | ||
[![License][license]](https://github.com/VencaKrecl/vuex-simple-cache/blob/master/LICENSE) | ||
[![Last test status][ci]](https://github.com/VencaKrecl/vuex-simple-cache/actions?query=workflow%3ACI) | ||
|
||
* simple cache for vuex action | ||
|
||
## How to install | ||
```bash | ||
npm install | ||
``` | ||
npm install vuex-simple-cache | ||
# OR | ||
yarn add vuex-simple-cache | ||
``` | ||
|
||
## How to use | ||
```js | ||
import Vue from 'vue'; | ||
import Vuex, { Store } from 'vuex'; | ||
import { cacheAction } from 'vuex-simple-cache'; | ||
|
||
Vue.use(Vuex); | ||
|
||
const store = new Store({}); | ||
|
||
store.registerModule('test', { | ||
state: { | ||
items: [{ name: 'cache' }], | ||
}, | ||
actions: { | ||
testAction: cacheAction('items', ({ commit }) => { // cache data for 30 seconds | ||
// call API | ||
const data = [{ name: 'cache' }]; | ||
|
||
commit('testMutation', data); | ||
|
||
return data; | ||
}, 30), | ||
}, | ||
mutation: { | ||
testMutation: (state, payload) => { | ||
state.items = payload | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
[npm]: https://img.shields.io/npm/v/@vencakrecl/vuex-simple-cache.svg?style=flat-square | ||
[license]: https://img.shields.io/npm/l/@vencakrecl/vuex-simple-cache.svg?style=flat-square | ||
[ci]: https://img.shields.io/github/workflow/status/VencaKrecl/vuex-simple-cache/CI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
{ | ||
"name": "@vencakrecl/vuex-simple-cache", | ||
"author": "Venca Krecl", | ||
"version": "1.0.0-alpha.1", | ||
"author": "Venca Krecl <[email protected]>", | ||
"description": "Simple cache for vuex action", | ||
"version": "1.0.0-alpha.6", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/VencaKrecl/vuex-simple-cache" | ||
}, | ||
"keywords": [ | ||
"vue", | ||
"vuex", | ||
"cache" | ||
], | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
|
@@ -19,7 +29,8 @@ | |
"lint": "tsdx lint", | ||
"prepare": "tsdx build", | ||
"size": "size-limit", | ||
"analyze": "size-limit --why" | ||
"analyze": "size-limit --why", | ||
"publish-package": "yarn publish --non-interactive --access public" | ||
}, | ||
"peerDependencies": {}, | ||
"husky": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters