Use settings from observable in chart
This commit is contained in:
+13
-4
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user