Reference Source
public class | source

PersistentStorage

You can directly use an instance of this class. PersistStorage

Extends:

* → PersistentStorage

Class for the persistent storage of data on a device using ASyncStorage.

Constructor Summary

Public Constructor
public

Creates an instance of AuthLoadingView

Method Summary

Public Methods
public

Checks if the parameter passed in is valid.

public

async getAllStoredKeys(onComplete: Function)

Get all the stored keys.

public

async removeAllData(keepKeys: List, onSuccess: Function, onError: Function)

Removes all stored keys in the AsyncStorage.

public

async removeData(key: string, onError: Function)

Removes an item from the persistent storage.

public

async retrieveData(key: string, onSuccess: Function, onError: Function)

Retrieves data from AsyncStorage and calls the success callback with the value.

public

async storeData(key: string, value: string/Number, onError: *)

Stores key, data using AsyncStorage to the device.

Public Constructors

public constructor(props: Object) source

Creates an instance of AuthLoadingView

Params:

NameTypeAttributeDescription
props Object

Component properties

Public Methods

public checkValid(val: string): Boolean source

Checks if the parameter passed in is valid.

Params:

NameTypeAttributeDescription
val string

A value to check

Return:

Boolean

true: Value is valid; false: Value is invalid

public async getAllStoredKeys(onComplete: Function) source

Get all the stored keys.

Params:

NameTypeAttributeDescription
onComplete Function

A callback function to call with an array of keys and an error if it failed. onComplete(error, keys)

public async removeAllData(keepKeys: List, onSuccess: Function, onError: Function) source

Removes all stored keys in the AsyncStorage.

Params:

NameTypeAttributeDescription
keepKeys List

A list of keys as strings to keep in local storage.

onSuccess Function

A callback function to call if all keys were successfully removed.

onError Function

A callback function to call if one or more keys threw an error when being removed.

public async removeData(key: string, onError: Function) source

Removes an item from the persistent storage.

Params:

NameTypeAttributeDescription
key string

The key for an item that should be removed

onError Function

A failure callback if an error occurs

public async retrieveData(key: string, onSuccess: Function, onError: Function) source

Retrieves data from AsyncStorage and calls the success callback with the value.

Params:

NameTypeAttributeDescription
key string

A key to fetch the data for

onSuccess Function

A success callback to process the data

onError Function

A failure callback to call if an error occurs

public async storeData(key: string, value: string/Number, onError: *) source

Stores key, data using AsyncStorage to the device.

Params:

NameTypeAttributeDescription
key string

A key to store data with

value string/Number

A value to store (can be string or number)

onError *

An error callback to call if there's an error while storing data