suspend Questions

2

Solved

While reviewing some code written in kotlin ,something caught my attention. I was looking about domain layer in some projects and in some of the projects, I saw that the suspend function and Flow w...
Fetch asked 16/4, 2023 at 21:14

10

I'm reading Kotlin Coroutine and know that it is based on suspend function. But what does suspend mean? Can Coroutine or function get suspended? From https://kotlinlang.org/docs/reference/coroutine...
Coworker asked 18/12, 2017 at 15:47

2

Solved

I'm a little confused. I know that if a function wants to work with coroutines, it should be declared as suspend For example: private suspend fun doSomething() { withContext(Dispatchers.IO) { ...
Northernmost asked 1/2, 2023 at 9:17

1

I am running a Debian-Jessy Server, that goes into S3 sleep mode after some hours network inactivity (I made a small bash script that checks it every two hours with crontab). Several seconds after ...
Engrain asked 23/11, 2014 at 16:26

2

Solved

I am a beginner studying coroutines. Not exactly, but I have a little understanding of what a coroutine is. The suspend function is also difficult, but with a little understanding. I'm studying ste...
Bacillary asked 7/2, 2022 at 20:36

2

Solved

I want to run to suspend functions in parallel and return result once the faster one of them returns result. I tried doing the following, but I think it only returns when both of them have finished...
Deportment asked 25/8, 2022 at 10:5

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

Solved

I am new to Arrow and try to establish my mental model of how its effects system works; in particular, how it leverages Kotlin's suspend system. My very vague understanding is as follows; if would ...
Jannjanna asked 31/1, 2022 at 8:4

1

Solved

Let's say we have a function suspend fun doSomething(value: Int): String { delay(1000L) return "abc_$value" } How to convert it to a function returning Mono? Are there any hidden probl...
Monolith asked 21/1, 2022 at 10:36

2

Solved

I've recently dove into Kotlin coroutines Since I use a lot of Google's libraries, most of the jobs is done inside Task class Currently I'm using this extension to suspend coroutine suspend fun &...
Neilson asked 13/5, 2018 at 11:49

2

Solved

I'm trying to test the following LocalDataSource function, NameLocalData.methodThatFreezes function, but it freezes. How can I solve this? Or How can I test it in another way? Class to be tested ...
Maggard asked 7/5, 2020 at 2:41

2

A coroutine started on Dispatchers.Main won't block the main thread while suspended. what does this mean? so when suspend function started on main thread when has some lines which takes longer, doe...
Eccentricity asked 7/4, 2020 at 4:27

2

Solved

I need to call a suspending function inside a suspendCoroutine block, before I call continuation.resume(). What is the appropriate way of doing that? private suspend fun someFunction() = suspendCor...
Sulfaguanidine asked 1/7, 2020 at 1:44

1

Solved

The question should be simple enough, but I couldn't find anything about it. I have an async Python program that contains a rather long-running task that I want to be able to suspend and restart at...
Frazee asked 18/3, 2021 at 8:43

0

In my Android app developed in Kotlin I'm not able to make the debugger stop on breakpoints set at runtime in a Dynamic Feature with suspend functions. If I set the breakpoint before launching the ...
Soutane asked 7/12, 2020 at 9:56

5

Solved

I have a program that I run only 1-2 hours a day. Is there a way to suspend the Azure server so I don't pay for it, then resume it later? How fast is it to suspend and then resume?
Strenuous asked 17/9, 2012 at 22:13

3

so usually when you have to make different API calls and wait, you do something like this: viewModelScope.launch { withContext(dispatcherProvider.heavyTasks) { val apiResponse1 = api.get1() //sus...
Xerography asked 14/7, 2020 at 9:30

1

Solved

Look at this example: fun f(block: suspend () -> Unit) { println("with suspend") } fun f(block: () -> Unit) { println("without suspend") } fun main() { f(suspend { }) // This call ca...
Murky asked 16/2, 2020 at 10:11

1

Solved

I was looking at the sample at https://github.com/android/architecture-samples/tree/dev-dagger/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/local of the dev-dag...
Polyploid asked 15/2, 2020 at 10:51

6

Solved

I'd like to write a short python script that puts my computer to sleep. I'Ve already searched the API but the only result on suspend has to do with delayed execution. What function does the trick ?...
Ness asked 22/9, 2011 at 15:37

1

Introduction Given two functions, foo() and foo(), the first one is standard and the second is suspendible fun foo(x: Int): Int { return 2*x } suspend fun foo(x: Int): Int { return 4*x } The...
Galvanotropism asked 3/1, 2020 at 13:9

4

Solved

I am trying to call a suspend function in the parameters of another suspend function. The compiler doesn't actually allow this. It is telling me that a suspend function must be called from a suspen...
Gastrovascular asked 22/12, 2019 at 6:1

2

Solved

I'm using Retrofit in order to make some network requests. I'm also using the Coroutines in combination with 'suspend' functions. My question is: Is there a way to improve the following code. The ...
Selectman asked 1/11, 2019 at 11:38

1

Solved

It looks like coEvery hangs when I am trying to mock suspend inline function. The code below works if remove inline modifier Function in storeApi: suspend inline fun getAllStores(): List<Store...
Interne asked 25/6, 2019 at 11:49

1

Solved

I want to call blocking a suspend function in a normal function, but does not block Thread to finishing suspend function and then return Response override fun intercept(chain: Interceptor.Chain): ...
Tace asked 1/6, 2019 at 19:52

© 2022 - 2024 — McMap. All rights reserved.