How to use the @react-native-community/async-storage.default function in @react-native-community/async-storage

To help you get started, we’ve selected a few @react-native-community/async-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stockulus / react-native-unique-id / tests / index.js View on Github external
const test = require('tape')

const uniqueId = require('../index')
const AsyncStorage = require('@react-native-community/async-storage').default

let theId

test('with no store', assert => {
  AsyncStorage.clear()
    .then(() => uniqueId())
    .then(id => {
      theId = id
      assert.ok(id)
      assert.end()
    })
    .catch(error => assert.error(error))
})

test('with store', assert => {
  uniqueId()
github jarden-digital / react-native-pincode / dist / index.js View on Github external
async componentWillMount() {
        await async_storage_1.default.getItem(this.props.timePinLockedAsyncStorageName || timePinLockedAsyncStorageNameDefault).then((val) => {
            this.setState({ pinLocked: !!val });
        });
    }
    render() {
github wix / wix-react-native-storybook-template / index.js View on Github external
get() {
      return require('@react-native-community/async-storage').default;
    },
  });
github jarden-digital / react-native-pincode / dist / src / utils.js View on Github external
exports.resetInternalStates = async (asyncStorageKeys) => {
    return await async_storage_1.default.multiRemove(asyncStorageKeys);
};
github jarden-digital / react-native-pincode / dist / src / PinCodeEnter.js View on Github external
this.endProcess = async (pinCode) => {
            if (!!this.props.endProcessFunction) {
                this.props.endProcessFunction(pinCode);
            }
            else {
                if (this.props.handleResult) {
                    this.props.handleResult(pinCode);
                }
                this.setState({ pinCodeStatus: utils_1.PinResultStatus.initial });
                this.props.changeInternalStatus(utils_1.PinResultStatus.initial);
                const pinAttemptsStr = await async_storage_1.default.getItem(this.props.pinAttemptsAsyncStorageName);
                let pinAttempts = pinAttemptsStr ? +pinAttemptsStr : 0;
                const pin = this.props.storedPin || this.keyChainResult;
                if (pin === pinCode) {
                    this.setState({ pinCodeStatus: utils_1.PinResultStatus.success });
                    async_storage_1.default.multiRemove([
                        this.props.pinAttemptsAsyncStorageName,
                        this.props.timePinLockedAsyncStorageName
                    ]);
                    this.props.changeInternalStatus(utils_1.PinResultStatus.success);
                    if (!!this.props.finishProcess)
                        this.props.finishProcess(pinCode);
                }
                else {
                    pinAttempts++;
                    if (+pinAttempts >= this.props.maxAttempts &&
                        !this.props.disableLockScreen) {
github jarden-digital / react-native-pincode / dist / src / ApplicationLocked.js View on Github external
async timer() {
        const timeDiff = +new Date(this.timeLocked) - +new Date();
        this.setState({ timeDiff: Math.max(0, timeDiff) });
        await delay_1.default(1000);
        if (timeDiff < 1000) {
            this.props.changeStatus(utils_1.PinResultStatus.initial);
            async_storage_1.default.multiRemove([
                this.props.timePinLockedAsyncStorageName,
                this.props.pinAttemptsAsyncStorageName
            ]);
        }
        if (!this.isUnmounted) {
            this.timer();
        }
    }
    componentWillUnmount() {
github stockulus / react-native-unique-id / index.js View on Github external
'use strict'

const AsyncStorage = require('@react-native-community/async-storage').default
const polygoat = require('polygoat')

let id

const generate = () => {
  const gen = count => {
    let out = ''
    for (let index = 0; index < count; index++) {
      out += (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
    }
    return out
  }

  return [gen(2), gen(1), gen(1), gen(1), gen(3)].join('-')
}
github jarden-digital / react-native-pincode / dist / src / PinCodeEnter.js View on Github external
this.props.timePinLockedAsyncStorageName
                    ]);
                    this.props.changeInternalStatus(utils_1.PinResultStatus.success);
                    if (!!this.props.finishProcess)
                        this.props.finishProcess(pinCode);
                }
                else {
                    pinAttempts++;
                    if (+pinAttempts >= this.props.maxAttempts &&
                        !this.props.disableLockScreen) {
                        await async_storage_1.default.setItem(this.props.timePinLockedAsyncStorageName, new Date().toISOString());
                        this.setState({ locked: true, pinCodeStatus: utils_1.PinResultStatus.locked });
                        this.props.changeInternalStatus(utils_1.PinResultStatus.locked);
                    }
                    else {
                        await async_storage_1.default.setItem(this.props.pinAttemptsAsyncStorageName, pinAttempts.toString());
                        this.setState({ pinCodeStatus: utils_1.PinResultStatus.failure });
                        this.props.changeInternalStatus(utils_1.PinResultStatus.failure);
                    }
                    if (this.props.onFail) {
                        await delay_1.default(1500);
                        this.props.onFail(pinAttempts);
                    }
                }
            }
        };
        this.state = { pinCodeStatus: utils_1.PinResultStatus.initial, locked: false };
github raindropio / mobile / src / data / modules / persistConfig.js View on Github external
import { createTransform } from 'redux-persist'

var throttle = 300

const ImmutableTransform = createTransform(
	//save
	(state, key) => state.asMutable ? state.asMutable({deep: true}) : state,
	//get
	(state, key) => Immutable(state)
)

let storage
if (RAINDROP_ENVIRONMENT == 'browser')
	storage = require('localforage')
else
	storage = require('@react-native-community/async-storage').default

/*
	//fix localStorage if exceeded the quota
	try{
		localStorage.setItem('_quotaTest', new Array(1024).join('a'))
		localStorage.removeItem('_quotaTest')
	}catch(e){
		localStorage.clear()
	}
*/

export default {
	key: 'primary',
	version: 1,
	whitelist: [
		'config',
github wix / wix-react-native-storybook-template / get-storybook.js View on Github external
export function getStorybook(resolveFunction, moduleName, options) {
  configureStoriesWithDecorators(resolveFunction, moduleName);
  return getStorybookUI({...options, asyncStorage: require('@react-native-community/async-storage').default});
}