@@ -21,6 +21,8 @@ import com.google.android.gms.tapandpay.issuer.PushTokenizeRequest
2121import kotlinx.coroutines.CoroutineScope
2222import kotlinx.coroutines.Dispatchers
2323import kotlinx.coroutines.launch
24+ import kotlinx.coroutines.SupervisorJob
25+ import kotlinx.coroutines.cancel
2426import com.expensify.wallet.Utils.getAsyncResult
2527import com.expensify.wallet.Utils.toCardData
2628import com.expensify.wallet.error.InvalidNetworkError
@@ -50,6 +52,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
5052 private val tapAndPayClient: TapAndPayClient = TapAndPay .getClient(activity)
5153 private var pendingCreateWalletPromise: Promise ? = null
5254 private var pendingPushTokenizePromise: Promise ? = null
55+ private val moduleScope = CoroutineScope (SupervisorJob () + Dispatchers .Main )
5356
5457 override fun initialize () {
5558 super .initialize()
@@ -58,6 +61,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
5861
5962 override fun invalidate () {
6063 super .invalidate()
64+ moduleScope.cancel()
6165 reactApplicationContext.removeActivityEventListener(cardListener)
6266 }
6367
@@ -119,7 +123,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
119123
120124 @ReactMethod
121125 override fun getSecureWalletInfo (promise : Promise ) {
122- CoroutineScope ( Dispatchers . Main ) .launch {
126+ moduleScope .launch {
123127 try {
124128 val walletId = getWalletIdAsync()
125129 val hardwareId = getHardwareIdAsync()
0 commit comments