Skip to content

Flagsmith Lambda not working inside suspendCoroutine #79

Description

@MamboBryan

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.

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.

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions