Category "coroutine"

How to call suspend function from Service Android?

How to provide scope or how to call suspend function from Service Android? Usually, activity or viewmodel provides us the scope, from where we can launch suspen

Kotlin Flows map

I have an issue regarding kotlin flow merging. See below fun. suspend fun method(filter: String): Flow<List<Model>> { // Search. val models: List&l

it seems that redisson distributed lock does not work

I'm testing whether distributed lock of redisson does work correctly, with kotlin and coroutine. runBlocking { repeat(1000) { launch {

Parallel processing values emitted by flow in Kotlin

Kotlin code runBlocking { flow { for (i in 0..4) { println("Emit $i") emit(i) }} .onEach { if (it%2 == 0) delay(20

How do I know if a Coroutine is still "waiting"? [closed]

All I can find online is "How to check if a coroutine is running", which is not what I want. Say if I have a coroutine with yield return new W

Suspend function 'callGetApi' should be called only from a coroutine or another suspend function

I am calling suspended function from onCreate(...) override fun onCreate(savedInstanceState: Bundle?) { ... ... callGetApi() } and the suspended

CoroutineScope Questions

At the Coroutine Scope, Why is the last println() called first when the launch block is called first?

CoroutineExceptionHandler not executed when provided as launch context

When I run this: fun f() = runBlocking { val eh = CoroutineExceptionHandler { _, e -> trace("exception handler: $e") } val j1 = launch(eh) {

Scheduling a coroutine with a context

There are plenty of tutorials that explain how it's easy to use coroutines in C++, but I've spent a lot of time getting how to schedule "detached" coroutines. A

how to use Coroutine in kotlin to call a function every second

i just created an app where my function getdata() call every second to fetch new data from server and updateui() function will update view in UI i don't use any