Flagsmith / Flagsmith/flagsmith-kotlin-android-client
Flagsmith Lambda not working inside `suspendCoroutine`
- Dominant language
- Kotlin
- Stars
- 8
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
I've been trying to check if a featureFlag exists inside `suspendCoroutine` with runblocking but the resulting lambda doesn't execute. Something like the one below.
```kotlin
fun isWalletEnabled(): Boolean = runBlocking {
Log.d(TAG, "isWalletEnabled: starting")
suspendCoroutine { continuation ->
Log.d(TAG, "isWalletEnabled: suspending")
flagsmith.hasFeatureFlag("is_wallet_enabled") {
Log.d(TAG, "isWalletEnabled: resulting -> ${it.getOrNull()}")
continuation.resumeWith(Result.success(it.getOrNull() ?: false))
}
}
}
```
Interestingly if I run it outside the `suspendCoroutine` it works and runs the lambda.
```kotlin
fun isWalletEnabled(): Boolean = runBlocking {
Log.d(TAG, "isWalletEnabled: starting")
flagsmith.hasFeatureFlag("is_wallet_enabled") {
Log.d(TAG, "isWalletEnabled: resulting -> ${it.getOrNull()}")
}
true
}
```
Anyway I could solve this?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.