Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add suspend version of getLastUpdateState() #8

Open
alibagherifam opened this issue Sep 25, 2024 · 1 comment
Open

Comments

@alibagherifam
Copy link

I'd like to suggest adding a suspend version of the getLastUpdateState() function.

Since Kotlin Coroutines are widely used, having a suspend version would simplify working with the API and make it more Kotlin idiomatic.

suspend fun BazaarUpdater.getLastUpdateState(
    context: Context
): UpdateResult = suspendCoroutine { cont ->
    getLastUpdateState(context = context) { result ->
        cont.resume(result)
    }
}

scope.launch {
   val result = BazaarUpdater.getLastUpdateState(context)
}
@hamid97m
Copy link
Collaborator

hamid97m commented Nov 7, 2024

Thank you, Ali, for your suggestion. We've actually considered this before. If you take a look at getLastUpdateState, you'll see that it retrieves the scope from your context using the retrieveScope(context) function. Our goal was to ensure ease of use, but this could create conflicts with the inner scope that we've drawn from context. Moreover, making getLastUpdateState suspendable could lead to memory leaks if developers mistakenly use the wrong scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants