coroutinescope Questions
7
What I want to achieve?
I have a task to download images but as the screen scrolls it will cancel previous downloads and start downloading new ones. I want that when it cancel the coroutine downloa...
Carboni asked 8/9, 2021 at 6:8
3
I need to handle current and previous value in flow collect, so I need some operator that acts like that:
----A----------B-------C-----|--->
---(null+A)---(A+B)---(B+C)--|--->
One idea is s...
Our asked 15/6, 2022 at 5:26
7
Solved
I want to store some preferences using DataStore. But the problem is that my application can have multiple users and therefor needs to store these preferences in separate files. I got a working exa...
Obvious asked 17/3, 2021 at 8:51
3
I know enough about coroutines-dispatchers-lifecycle scopes-async await.
And it is obvious that all scope.launch functions returns job which we can manage coroutine lifecycle.
Only thing i can not ...
Chirm asked 18/1, 2022 at 22:21
1
Solved
I am trying to understand structured concurrency in Kotlin and I am unable to wrap my head across this piece of code.
fun main(): Unit = runBlocking {
other(this)
}
suspend fun other(scope: Corou...
Retentivity asked 1/1, 2023 at 1:47
3
Solved
I wrote this code in Kotlin to download some API information using Coroutines for downloading the data. However, the code shows a lot of warnings stating the message as "Inappropriate blocking...
Sarisarid asked 7/7, 2020 at 7:20
2
Is there any difference between this two approaches?
runBlocking {
launch(coroutineDispatcher) {
// job
}
}
GlobalScope.launch(coroutineDispatcher) {
// job
}
Legislative asked 23/2, 2019 at 13:35
5
Solved
Is there a way to return value from a coroutine scope? for example like this:
suspend fun signUpUser(signUpData : SignUpUserRequest) : User {
CoroutineScope(Dispatchers.IO).launch() {
val respon...
Cooley asked 18/7, 2020 at 7:36
6
Solved
Can anyone give clarity between functions CoroutineScope() and coroutineScope()?
When I tried to check in source, I found that both of them are functions of CoroutineScope.kt. Additionally, corout...
Vernation asked 17/12, 2019 at 6:42
2
I want create MainCoroutineRule.
But TestCoroutineScope deprecated since 1.6.0.
How can I migrate it?
Below is my MainCoroutineRule
class MainCoroutineRule(
val dispatcher: TestCoroutineDispatcher...
Keratinize asked 4/3, 2022 at 7:50
4
Solved
I have a scenario where my code has to send an api call and move on with its work (which contains another api call) without waiting for the result of the first call.
Right now I do this in my viewm...
Betide asked 1/9, 2020 at 23:10
1
Solved
There are different ways of launching a coroutine in Kotlin. I found a couple of examples where GlobalScope and CoroutineScope are used. But the latter one is being created directly when launching ...
Westernmost asked 5/1, 2022 at 12:43
1
Solved
Is the below exactly the same?
lifecycleScope.launch {
whenStarted {
// Do something
}
}
and
lifecycleScope.launchWhenStarted {
// Do something
}
Or they do have some distinct purpose, henc...
Ludeman asked 26/12, 2021 at 7:38
1
Solved
Recently, I applied Coroutines into my project everything seems to be fine but today I meet a problem Upload file/image into server using Coroutine + Retrofit.
It seems that there is no solution fo...
Decision asked 21/12, 2021 at 9:49
2
Solved
Tried to use room api and had to deal with asynchronous tasks you know why.
I chose kotlin coroutines and androidx.lifecycle. Tried to write some code and got 2 errors displaying in IDE
Cannot acce...
Anaesthesia asked 4/12, 2021 at 15:8
2
Solved
I want to know whether coroutineScope will be auto-canceled after its work is finished. Say I create a coroutineScope in a custom class Rather Than ViewModel class or Fragment / Activity class:
cla...
Aloft asked 16/8, 2021 at 13:57
2
I'm refactoring some Kotlin code that currently launches coroutines on the GlobalScope to a structured concurrency-based approach. I need to join all of the jobs launched in my code before the JVM ...
Kinnon asked 2/2, 2021 at 3:58
2
Solved
I'm calling launch inside a coroutinescope but it does not execute. Snackbar action listener is executing but the launch block is not executing for some reason.
CoroutineScope(Dispatchers.Main).lau...
Micronesia asked 18/10, 2020 at 7:3
1
I need to use coroutines inside a custom view. After watching this talk, I believe my best option is to use lifecycleScope as the coroutine scope, so that it will be automatically cancelled when li...
Autoharp asked 24/9, 2020 at 12:38
2
Solved
If the operations inside CoroutineScope(job+Dispatchers.Main){...} run on the main thread then how come it does not violate Android's requirement that slow (blocking) operations (Networking etc.) a...
Mills asked 18/2, 2020 at 3:56
1
Solved
Based on this post throttleFirst function:
fun <T> throttleFirst(
skipMs: Long = 700L,
scope: CoroutineScope = viewModelScope,
action: (T) -> Unit
): (T) -> Unit {
var throttleJob:...
Bontebok asked 19/12, 2019 at 15:48
3
Solved
I am calling suspended function from onCreate(...)
override fun onCreate(savedInstanceState: Bundle?) {
...
...
callGetApi()
}
and the suspended function is:-
suspend fun callGetApi() {....}...
Whistling asked 26/12, 2018 at 7:12
1
Solved
withContext
suspend fun <T> withContext(
context: CoroutineContext,
block: suspend CoroutineScope.() -> T
): T (source)
Calls the specified suspending block with a given coroutine conte...
Burgonet asked 2/7, 2019 at 19:1
3
Solved
in kotlin coroutines doc, it explains the "difference between runBlocking and coroutineScope":
Scope builder
In addition to the coroutine scope provided by different builders, it is poss...
Thickskinned asked 16/5, 2019 at 15:14
1
Hi I am using Kotlin coroutine library in a project.
The below method calls a suspend function which return a boolean value.
fun isNetworkAvailable(context: Context?): Boolean {
//return checkNe...
Ruinous asked 23/5, 2019 at 13:12
1 Next >
© 2022 - 2025 — McMap. All rights reserved.