Skip to main content
Filter by
Sorted by
Tagged with
Best practices
2 votes
0 replies
25 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
-2 votes
0 answers
86 views

I am trying to build a horizontally scrolling list of category chips in Jetpack Compose, similar to this design: I want the categories to: scroll horizontally look like rounded chips highlight the ...
soumik's user avatar
  • 11
4 votes
2 answers
148 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
26 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
0 answers
190 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,824
0 votes
3 answers
146 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
2 votes
1 answer
88 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
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
1 vote
2 answers
172 views

I have something like the following in Kotlin: class A { fun a(): Unit = TODO() } fun foo(a: A) { // Do something CoroutineScope(Dispatchers.IO).launch { delay(1000) a.a() ...
riccardo.cardin's user avatar
0 votes
1 answer
71 views

I switch between “chart windows” (weekly, monthly…). Upstream data is a hot Flow (think Room). To keep the list size stable, I render 30 fixed slots: real items in the first n, placeholders in the ...
Klem Lloyd Mwenya's user avatar
0 votes
1 answer
97 views

Context and prior understanding: In Node.JS, I/O code is run in a thread pool / event loop parallel to the main JavaScript thread. async code is never truly blocking per-se, unless a blocking call (e....
anon's user avatar
  • 697
0 votes
1 answer
59 views

I have a Bluetooth tracker app. I try it to be clean. Everything related to scan is encapsulated in one class. I am injecting with Hilt. The problem is when I scan via Bluetooth for 10s, I emit the ...
sepideh's user avatar
  • 49
0 votes
1 answer
97 views

I am rather new to Ktor and try to upload a file to my server. This is the route: fun Application.module() { install(ContentNegotiation) { json() } routing { post("/upload") { ...
KCD's user avatar
  • 698
2 votes
1 answer
244 views

I need to use Kotlin' coroutines and the retrofit2 library to make http requests. When I run the following code, the http request works as expected (posts is printed), but after this, the program ...
Berk7871's user avatar
  • 293
0 votes
1 answer
41 views

i have this code my viewmodel init val scope = CoroutineScope(Dispatchers.Main ) var child1:Job = Job() var child2 : Deferred<Unit> = CompletableDeferred(Unit) child1 =scope....
sepideh's user avatar
  • 49
0 votes
1 answer
101 views

I’m looking for some insight into this issue I’m having with my Ktor/exposed application… If I do the following in a KTOR route, after the newSuspendedTransaction block is closed, TransactionManager....
prule's user avatar
  • 2,584
-1 votes
2 answers
160 views

I have the following class I am trying to test. I am using mockito as that is the library I am using class ConsentUpdatedBroadcastReceiverImp @Inject constructor( private val context: Context, ...
ant2009's user avatar
  • 22.7k
1 vote
2 answers
217 views

I have this block: try { withTimeout(200) { val response = datafetcher.fetchData(request) } } catch (TimeoutCancellationException e) { returns response with some error message added } I am ...
mulafar p's user avatar
0 votes
1 answer
36 views

// code inside viewModel viewModelScope.launch(Dispatchers.IO) { try { tempUsecase.coroutineTest( coroutineScope = this, ) } catch (e: Exception) { ...
Learner_Android's user avatar
1 vote
1 answer
79 views

I have a code that uses withTimeout as follows. suspend fun send(timeoutMillis: Long): Int? { val result: Int? = withTimeoutOrNull(timeoutMillis) { doSomething() } return result } suspend ...
SpeedRacer's user avatar
2 votes
1 answer
187 views

I'm encountering a discrepancy in retrieving a custom CoroutineContext.Element (TraceContextElement) depending on the environment (test vs. production) and how I access the context within a launched ...
happy_friend's user avatar
0 votes
1 answer
75 views

There is a very common pattern when dealing a remote service: A sequential series of calls to the service, each of which invokes a callback, asynchronously, when complete. I believe, for instance, ...
G. Blake Meike's user avatar
0 votes
1 answer
256 views

I have a ProfileViewModel where I load the user profile when the user lands on the screen. To achieve this, I use stateIn so that the profile is fetched automatically. Now, I want to modify ...
Vivek Modi's user avatar
  • 7,859
1 vote
0 answers
55 views

I have the following flow operator: fun <T> Flow<T>.bufferedWithTimeout( maxBufferSize: Int, timeout: Duration ): Flow<List<T>> { require(maxBufferSize > 0) { &...
Calamity's user avatar
  • 1,060
1 vote
1 answer
91 views

org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1 ConflatedBufferedChannel with capacity = 1. If onBufferOverflow is configured as BufferOverflow.DROP_OLDEST trySend returns success. ...
toffor's user avatar
  • 1,309

1
2 3 4 5
102