Skip to main content
Best practices
3 votes
0 replies
36 views

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 ...
Domz's user avatar
  • 11
3 votes
1 answer
91 views

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 : ...
Benjamin K's user avatar
0 votes
2 answers
58 views

I am trying to test the number of times a Flow is collected - runTest { var count = 0 backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) { dao.getEntities().collect { ...
jL4's user avatar
  • 1,242
4 votes
2 answers
154 views

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 ...
Yann Djomo's user avatar
0 votes
0 answers
70 views

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, ...
Prexi's user avatar
  • 13
0 votes
0 answers
27 views

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 ...
Jakub Bochenski's user avatar
-2 votes
2 answers
123 views

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 ...
Wladyslaw Skiba's user avatar
3 votes
0 answers
192 views

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. ...
Brian White's user avatar
  • 8,844
1 vote
1 answer
81 views

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. ...
Vivek Modi's user avatar
  • 7,859
0 votes
3 answers
148 views

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 ...
Prexi's user avatar
  • 13
0 votes
1 answer
66 views

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 ...
Mohammadreza Khahani's user avatar
2 votes
1 answer
89 views

I have some code similar to this: class Foo { var x = 0 init { GlobalScope.launch { while (true) { delay(1000) x += 1 }...
Seggan's user avatar
  • 216
0 votes
1 answer
167 views

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 ...
msc87's user avatar
  • 1,037
0 votes
1 answer
37 views

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, ...
EnergyKickman's user avatar
5 votes
0 answers
143 views

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 ...
AndroidKotlinNoob's user avatar

15 30 50 per page
1
2 3 4 5
338