Use settings from observable in chart

This commit is contained in:
Julia Friesel
2018-08-22 08:43:41 +02:00
parent d5f9e6c639
commit c597a654d8
4 changed files with 53 additions and 54 deletions
+13 -4
View File
@@ -1,13 +1,22 @@
import { AsyncStorage } from 'react-native'
import Observable from 'obv'
import config from '../config'
export const tempScaleObservable = Observable()
getTempScale()
setTempScaleInitially()
async function getTempScale() {
async function setTempScaleInitially() {
const result = await AsyncStorage.getItem('tempScale')
if (!result) return result
tempScaleObservable.set(JSON.parse(result))
let value
if (result) {
value = JSON.parse(result)
} else {
value = {
min: config.temperatureScale.defaultLow,
max: config.temperatureScale.defaultHigh
}
}
tempScaleObservable.set(value)
}
export async function saveTempScale(scale) {