Commit 7245aaa 1 parent 3010015 commit 7245aaa Copy full SHA for 7245aaa
File tree 1 file changed +14
-0
lines changed
lib/sessionManager/stores
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,15 @@ import { splitString } from "../utils.js";
4
4
5
5
let expoSecureStore : typeof import ( "expo-secure-store" ) | undefined = undefined ;
6
6
7
+ async function waitForExpoSecureStore ( ) {
8
+ let tries = 0 ;
9
+ while ( ! expoSecureStore && tries < 20 ) {
10
+ console . log ( 'waiting' ) ;
11
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
12
+ tries ++ ;
13
+ }
14
+ }
15
+
7
16
/**
8
17
* Provides a expo local store based session manager implementation for the browser.
9
18
* @class ExpoSecureStore
@@ -42,6 +51,7 @@ export class ExpoSecureStore<V = StorageKeys> implements SessionManager<V> {
42
51
itemKey : V | StorageKeys ,
43
52
itemValue : unknown ,
44
53
) : Promise < void > {
54
+ await waitForExpoSecureStore ( ) ;
45
55
// clear items first
46
56
await this . removeSessionItem ( itemKey ) ;
47
57
@@ -66,6 +76,8 @@ export class ExpoSecureStore<V = StorageKeys> implements SessionManager<V> {
66
76
* @returns {unknown | null }
67
77
*/
68
78
async getSessionItem ( itemKey : V | StorageKeys ) : Promise < unknown | null > {
79
+ await waitForExpoSecureStore ( ) ;
80
+
69
81
const chunks = [ ] ;
70
82
let index = 0 ;
71
83
@@ -91,6 +103,8 @@ export class ExpoSecureStore<V = StorageKeys> implements SessionManager<V> {
91
103
* @returns {void }
92
104
*/
93
105
async removeSessionItem ( itemKey : V | StorageKeys ) : Promise < void > {
106
+ await waitForExpoSecureStore ( ) ;
107
+
94
108
let index = 0 ;
95
109
96
110
let chunk = await expoSecureStore ! . getItemAsync (
You can’t perform that action at this time.
0 commit comments