Skip to content

Commit

Permalink
feat(redux): add wechat storage methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Genuifx committed Jul 5, 2020
1 parent 6f3b05b commit 4f97273
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/wxa-redux/libs/wx.storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {storage} from '@wxa/core';

export default {
getItem(key) {
return new Promise((r, rj)=>{
r(storage.get(key));
});
},
setItem(key, string) {
return new Promise((r)=>{
r(storage.set(key, string));
});
},
removeItem(key) {
return new Promise((r)=>r(storage.remove(key)));
},
};
25 changes: 25 additions & 0 deletions packages/wxa-redux/libs/wx.storage.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _core = require('@wxa/core');

exports.default = {
getItem: function getItem(key) {
return new Promise(function (r, rj) {
r(_core.storage.get(key));
});
},
setItem: function setItem(key, string) {
return new Promise(function (r) {
r(_core.storage.set(key, string));
});
},
removeItem: function removeItem(key) {
return new Promise(function (r) {
return r(_core.storage.remove(key));
});
}
};
3 changes: 2 additions & 1 deletion packages/wxa-redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "redux for wxa ",
"main": "./dist/index.js",
"scripts": {
"build": "babel src --out-dir ./dist/",
"build:lib": "babel ./libs/wx.storage.js --out-file ./libs/wx.storage.min.js",
"build": "babel src --out-dir ./dist/ && npm run build:lib",
"prepublishOnly": "npm run build",
"dev": "babel --watch src --out-dir ./dist/",
"test": "jest",
Expand Down

0 comments on commit 4f97273

Please sign in to comment.