5,063 questions
Best practices
3
votes
0
replies
36
views
Testing with corroutines
Let's say I have Worker class and I want to do long running tasks in the background until user stops it or it is cancelled. It changes state of the class while doing the work and I want to write tests ...
3
votes
1
answer
91
views
Does combine conflate flows?
When I use combine() on two flow, it's not supposed to conflate/skip values. But when I collect a combine of 2 flows in a Coroutine, some values are randomly skipped.
Link to the kotlin playground : ...
0
votes
2
answers
58
views
Why is my continuous flow test code flaky?
I am trying to test the number of times a Flow is collected -
runTest {
var count = 0
backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) {
dao.getEntities().collect {
...
4
votes
2
answers
154
views
How to call a composable function after a certain time in Jetpack Compose?
When my application starts, I launch an animation. Now I would like to switch to another component (navbar) after 30 seconds. In my research, I saw that the delay function from the Kotlin Coroutines ...
0
votes
0
answers
70
views
How does async exception propagation rally works?
I’ve read in multiple places that async can swallow exceptions if we don’t call await, but as far as I can see, it almost always throws them regardless of whether await is used or not.
For example, ...
0
votes
0
answers
27
views
Use suspend function with Vert.x Kafka Consumer?
I want to use suspend function in a handler for KafkaConsumer.
This is what I have so far, but I'm not sure about exception handling.
CoroutineEventBusSupport would call fail() on the message and ...
-2
votes
2
answers
123
views
Waiting for coroutine to end it's job to trigger an event [closed]
I have an Activity that is responsible for creating a new entry in the database. In this activity, a button launches a coroutine to do all the database-related stuff, and when it's done, navigate to ...
3
votes
0
answers
192
views
Objectify with Kotlin Ktor 3.3
Objectify v6.1.3
With Kotlin and Ktor 3.1, I was calling ObjectifyService.begin() within the init {} block of my request handler base class and then closing that context once the request was finished. ...
1
vote
1
answer
81
views
Differences between long-running Flow processing with transform() and flatMapLatest()
I have a data stream coming from the server. The server does not provide any information about when the next piece of data will arrive. I have a Flow in my repository that emits data as it arrives. ...
0
votes
3
answers
148
views
Are there any real difference between GlobalScope and CoroutineScope?
I'm trying to understand the difference between the 2.
If a CoroutineScope is not tied to any lifecycle-aware component, then I think they behave the same:
If Im not passing any context to ...
0
votes
1
answer
66
views
Is kotlin coroutine Job's status is reliable for concurrency control?
I've read this sentence in the Java Concurrency in Practice book that:
The result of Thread.getState should not be used for concurrency
control, and is of limited usefulness for testing—its primary ...
2
votes
1
answer
89
views
How can I tie a coroutine's lifetime to the lifetime of an object?
I have some code similar to this:
class Foo {
var x = 0
init {
GlobalScope.launch {
while (true) {
delay(1000)
x += 1
}...
0
votes
1
answer
167
views
Strictly depending on Coroutine 1.8.1 to use BroadcastChannel with Kotlin 2
I have a code base which is tightly coupled with BoradcastChannel and I can't update that for now. But I want to upgrade the dependencies to their latest, use kotlin2 and compose.
I have changed my ...
0
votes
1
answer
37
views
Creating activity prevents spinner from spinning in Android
I have 2 activities in my app. When another one is called there is a spinner but it doesn't spin. I think it may be because the main thread is stuck.
I moved all background tasks to Dispatchers.IO, ...
5
votes
0
answers
143
views
Why is the action of Mutex.withLock not marked as suspend?
The action parameter of the withLock function is a lambda without the suspend keyword. Is there a reason for this missing keyword?
In most cases, this lack of the suspend keyword isn't an issue ...