react-global-state-hooks 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/GlobalStore.d.ts.map +1 -1
- package/lib/GlobalStore.js +2 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -689,4 +689,6 @@ The setMetadata is part of the store tools, so it can be used in the actions, bu
|
|
|
689
689
|
|
|
690
690
|
...
|
|
691
691
|
|
|
692
|
+
For seen a running example of the hooks, you can check the following link: [react-global-state-hooks-example](https://johnny-quesada-developer.github.io/react-global-state-hooks-example/)
|
|
693
|
+
|
|
692
694
|
# That's it for now!! hope you enjoy coding!!
|
package/lib/GlobalStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalStore.d.ts","sourceRoot":"","sources":["../src/GlobalStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GlobalStore.d.ts","sourceRoot":"","sources":["../src/GlobalStore.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAIhD,OAAO,EAGL,WAAW,IAAI,eAAe,EAC/B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,WAAW,CACtB,MAAM,EACN,SAAS,GAAG,IAAI,EAChB,YAAY,SACR,sBAAsB,CAAC,MAAM,EAAE,SAAS,CAAC,GACzC,WAAW,CAAC,MAAM,CAAC,GACnB,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAC9B,SAAQ,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC;IACxD;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAErE;;;;;;;;;;;SAWK;gBAEH,KAAK,EAAE,MAAM,EACb,EACE,MAAM,EAAE,YAAY,EACpB,GAAG,MAAM,EACV,GAAE,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAM,EAC1D,YAAY,GAAE,YAAY,GAAG,IAAW;IAsB1C,SAAS,CAAC,oBAAoB,aAoB5B;IAEF,SAAS,CAAC,oBAAoB,eAkB5B;IAEF;;;OAGG;IACH,SAAS,CAAC,MAAM,kBAEb,yBAAyB,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,mBAgB1D;IAEF,SAAS,CAAC,cAAc,aAEtB;IAEF;;;;;SAKK;IACL,SAAS,CAAC,QAAQ;eAIT,MAAM;0BACK,MAAM,QAAQ,CAAC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;eAoB9D;CACH"}
|
package/lib/GlobalStore.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GlobalStore = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const react_dom_1 = tslib_1.__importDefault(require("react-dom"));
|
|
6
5
|
tslib_1.__exportStar(require("react-native-global-state-hooks"), exports);
|
|
6
|
+
const react_dom_1 = tslib_1.__importDefault(require("react-dom"));
|
|
7
7
|
const react_native_global_state_hooks_1 = require("react-native-global-state-hooks");
|
|
8
8
|
class GlobalStore extends react_native_global_state_hooks_1.GlobalStore {
|
|
9
9
|
/**
|
|
@@ -22,12 +22,10 @@ class GlobalStore extends react_native_global_state_hooks_1.GlobalStore {
|
|
|
22
22
|
var _b;
|
|
23
23
|
var { onInit: onInitConfig } = _a, config = tslib_1.__rest(_a, ["onInit"]);
|
|
24
24
|
if (setterConfig === void 0) { setterConfig = null; }
|
|
25
|
-
debugger;
|
|
26
25
|
const decrypt = (config === null || config === void 0 ? void 0 : config.decrypt) === undefined ? (_b = config === null || config === void 0 ? void 0 : config.encrypt) !== null && _b !== void 0 ? _b : true : config === null || config === void 0 ? void 0 : config.decrypt;
|
|
27
26
|
super(state, Object.assign({ metadata: null, encrypt: true, decrypt }, (config !== null && config !== void 0 ? config : {})), setterConfig);
|
|
28
27
|
this.setLocalStorageValue = () => {
|
|
29
28
|
const { localStorageKey } = this.config;
|
|
30
|
-
debugger;
|
|
31
29
|
let stateToStore = (0, react_native_global_state_hooks_1.formatToStore)(this.getStateClone(), {
|
|
32
30
|
stringify: true,
|
|
33
31
|
});
|
|
@@ -41,10 +39,9 @@ class GlobalStore extends react_native_global_state_hooks_1.GlobalStore {
|
|
|
41
39
|
};
|
|
42
40
|
this.getLocalStorageValue = () => {
|
|
43
41
|
const { localStorageKey } = this.config;
|
|
44
|
-
debugger;
|
|
45
42
|
let storedState = localStorage.getItem(localStorageKey);
|
|
46
43
|
const { decrypt } = this.config;
|
|
47
|
-
if (decrypt) {
|
|
44
|
+
if (decrypt && storedState) {
|
|
48
45
|
const isDecryptCallback = typeof decrypt === 'function';
|
|
49
46
|
const decryptCallback = (isDecryptCallback ? decrypt : (value) => atob(value));
|
|
50
47
|
storedState = decryptCallback(storedState);
|
package/package.json
CHANGED