15
15
import com .facebook .react .bridge .Arguments ;
16
16
import com .facebook .react .bridge .Callback ;
17
17
import com .facebook .react .bridge .GuardedAsyncTask ;
18
- import com .facebook .react .bridge .LifecycleEventListener ;
19
18
import com .facebook .react .bridge .ReactApplicationContext ;
20
19
import com .facebook .react .bridge .ReactContextBaseJavaModule ;
21
20
import com .facebook .react .bridge .ReactMethod ;
34
33
35
34
@ ReactModule (name = AsyncStorageModule .NAME )
36
35
public final class AsyncStorageModule
37
- extends NativeAsyncStorageModuleSpec implements ModuleDataCleaner .Cleanable , LifecycleEventListener {
36
+ extends NativeAsyncStorageModuleSpec implements ModuleDataCleaner .Cleanable {
38
37
39
38
// changed name to not conflict with AsyncStorage from RN repo
40
39
public static final String NAME = "RNCAsyncStorage" ;
@@ -60,11 +59,12 @@ public AsyncStorageModule(ReactApplicationContext reactContext) {
60
59
@ VisibleForTesting
61
60
AsyncStorageModule (ReactApplicationContext reactContext , Executor executor ) {
62
61
super (reactContext );
62
+
63
63
// The migration MUST run before the AsyncStorage database is created for the first time.
64
64
AsyncStorageExpoMigration .migrate (reactContext );
65
65
66
66
this .executor = new SerialExecutor (executor );
67
- reactContext . addLifecycleEventListener ( this );
67
+
68
68
// Creating the database MUST happen after the migration.
69
69
mReactDatabaseSupplier = ReactDatabaseSupplier .getInstance (reactContext );
70
70
}
@@ -81,8 +81,10 @@ public void initialize() {
81
81
}
82
82
83
83
@ Override
84
- public void onCatalystInstanceDestroy () {
84
+ public void invalidate () {
85
85
mShuttingDown = true ;
86
+ // ensure we close database when activity is destroyed
87
+ mReactDatabaseSupplier .closeDatabase ();
86
88
}
87
89
88
90
@ Override
@@ -93,18 +95,6 @@ public void clearSensitiveData() {
93
95
mReactDatabaseSupplier .clearAndCloseDatabase ();
94
96
}
95
97
96
- @ Override
97
- public void onHostResume () {}
98
-
99
- @ Override
100
- public void onHostPause () {}
101
-
102
- @ Override
103
- public void onHostDestroy () {
104
- // ensure we close database when activity is destroyed
105
- mReactDatabaseSupplier .closeDatabase ();
106
- }
107
-
108
98
/**
109
99
* Given an array of keys, this returns a map of (key, value) pairs for the keys found, and
110
100
* (key, null) for the keys that haven't been found.
0 commit comments