diff --git a/local-storage/index.js b/local-storage/index.js index 5fff233..e64bc18 100644 --- a/local-storage/index.js +++ b/local-storage/index.js @@ -1,11 +1,17 @@ import { AsyncStorage } from 'react-native' +import Observable from 'obv' -export async function getTempScale() { +export const tempScaleObservable = Observable() +getTempScale() + +async function getTempScale() { const result = await AsyncStorage.getItem('tempScale') if (!result) return result - return JSON.parse(result) + tempScaleObservable.set(JSON.parse(result)) } export async function saveTempScale(scale) { - return AsyncStorage.setItem('tempScale', JSON.stringify(scale)) + await AsyncStorage.setItem('tempScale', JSON.stringify(scale)) + tempScaleObservable.set(scale) } + diff --git a/package-lock.json b/package-lock.json index 66bd9e7..2df2c48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3732,8 +3732,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -3751,13 +3750,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3770,18 +3767,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -3884,8 +3878,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -3895,7 +3888,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3908,20 +3900,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -3938,7 +3927,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4011,8 +3999,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -4022,7 +4009,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4098,8 +4084,7 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -4129,7 +4114,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4147,7 +4131,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4186,13 +4169,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.2", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -6033,6 +6014,11 @@ } } }, + "obv": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/obv/-/obv-0.0.1.tgz", + "integrity": "sha1-yyNhBjQVNvDaxIFeBnCCIcrX+14=" + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", diff --git a/package.json b/package.json index d1c38e5..d35c6b1 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "js-joda": "^1.8.2", "moment": "^2.22.1", "object-path": "^0.11.4", + "obv": "0.0.1", "react": "16.4.1", "react-native": "^0.56.0", "react-native-calendars": "^1.19.3",