Skip to content

Commit

Permalink
fix: React Native build does not maintain arrow functions and causes …
Browse files Browse the repository at this point in the history
…error with AsyncStorage (#1587)
  • Loading branch information
dplewis authored Nov 1, 2022
1 parent 0ab17e6 commit 8aeaa4f
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/StorageController.react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@
* @flow
* @private
*/

import CoreManager from './CoreManager';

const StorageController = {
async: 1,

getAsyncStorage(): any {
return CoreManager.getAsyncStorage();
},

getItemAsync(path: string): Promise {
return new Promise((resolve, reject) => {
this.getAsyncStorage().getItem(path, function (err, value) {
CoreManager.getAsyncStorage().getItem(path, (err, value) => {
if (err) {
reject(err);
} else {
Expand All @@ -33,7 +28,7 @@ const StorageController = {

setItemAsync(path: string, value: string): Promise {
return new Promise((resolve, reject) => {
this.getAsyncStorage().setItem(path, value, function (err, value) {
CoreManager.getAsyncStorage().setItem(path, value, (err, value) => {
if (err) {
reject(err);
} else {
Expand All @@ -45,7 +40,7 @@ const StorageController = {

removeItemAsync(path: string): Promise {
return new Promise((resolve, reject) => {
this.getAsyncStorage().removeItem(path, function (err) {
CoreManager.getAsyncStorage().removeItem(path, (err) => {
if (err) {
reject(err);
} else {
Expand All @@ -57,7 +52,7 @@ const StorageController = {

getAllKeysAsync(): Promise {
return new Promise((resolve, reject) => {
this.getAsyncStorage().getAllKeys(function (err, keys) {
CoreManager.getAsyncStorage().getAllKeys((err, keys) => {
if (err) {
reject(err);
} else {
Expand All @@ -69,7 +64,7 @@ const StorageController = {

multiGet(keys: Array<string>): Promise<Array<Array<string>>> {
return new Promise((resolve, reject) => {
this.getAsyncStorage().multiGet(keys, function (err, result) {
CoreManager.getAsyncStorage().multiGet(keys, (err, result) => {
if (err) {
reject(err);
} else {
Expand All @@ -81,7 +76,7 @@ const StorageController = {

multiRemove(keys: Array<string>): Promise {
return new Promise((resolve, reject) => {
this.getAsyncStorage().multiRemove(keys, function (err) {
CoreManager.getAsyncStorage().multiRemove(keys, (err) => {
if (err) {
reject(err);
} else {
Expand All @@ -92,7 +87,7 @@ const StorageController = {
},

clear() {
return this.getAsyncStorage().clear();
return CoreManager.getAsyncStorage().clear();
},
};

Expand Down

0 comments on commit 8aeaa4f

Please sign in to comment.