Export temp scale settings as observable

This commit is contained in:
Julia Friesel
2018-08-21 21:50:47 +02:00
parent 896f407f46
commit d5f9e6c639
3 changed files with 26 additions and 33 deletions
+9 -3
View File
@@ -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)
}