mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-04-22 20:48:03 +00:00
b3e9b70341
* add readme * react-native example app * update readme * add ios-cli dep * revert package.json change * update readme * update readme * don't auto launch metro * add react native scripts * nohoist @react-native-community/** * update readme * undo wrong README change * remove react-native root dep * copyright headers * semi-style * add default gitignore * finish linting * remove test for now * fix typescript errors * fix linting * update scripts * update deps and version * update readme * remove accidental dep * update readme * bump deps * update yarn.lock * actually update yarn.lock * fix yarn.lock conflicts by updating exampleReactNative deps
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
// Copyright 2017-2019 @polkadot/example-react authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
/* eslint-disable no-global-assign */
|
|
|
|
import AsyncStorage from '@react-native-community/async-storage';
|
|
|
|
class Storage {
|
|
constructor () {
|
|
this.dataMap = new Map();
|
|
this.loading = true;
|
|
}
|
|
|
|
init = async () => {
|
|
const keys = await AsyncStorage.getAllKeys();
|
|
const data = await AsyncStorage.multiGet(keys);
|
|
data.forEach(this.saveItem.bind(this));
|
|
this.loading = false;
|
|
return [...data];
|
|
}
|
|
|
|
getItem = key => {
|
|
return this.dataMap.get(key);
|
|
}
|
|
|
|
setItem = (key, value) => {
|
|
this.dataMap.set(key, value);
|
|
return AsyncStorage.setItem(key, value);
|
|
}
|
|
|
|
remove = key => {
|
|
this.dataMap.delete(key);
|
|
return AsyncStorage.removeItem(key);
|
|
}
|
|
|
|
saveItem = item => {
|
|
this.dataMap.set(item[0], item[1]);
|
|
}
|
|
}
|
|
|
|
// Set global process variable expected by some classes.
|
|
global.process = require('process');
|
|
global.navigator.userAgent = '';
|
|
window = { location: { host: '' } };
|
|
global.localStorage = new Storage();
|