Flagsmith / Flagsmith/flagsmith-kotlin-android-client

Flagsmith Lambda not working inside `suspendCoroutine`

Open
#79 1 comment 0 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.