magnumrocha
02/20/2020, 4:32 PMThiyagu
02/23/2020, 8:40 PMFlow
. Feedback are welcome.
https://thiyagu06.github.io/reactive-sqs-consumer/ursus
02/26/2020, 3:51 AMTimur Atakishiev
02/27/2020, 8:56 AMrunBlocking {
while (true) {
someList.forEach {
launch { someFunction(it) }
}
delay(1000)
}
}
Hi guys, I got a problem, I can not test whether the someFunction is going to run in multiple coroutines, is any way how to do it?corneil
02/28/2020, 5:15 AMKotlinIsMyFav
02/28/2020, 6:02 PMKotlinIsMyFav
02/28/2020, 6:02 PMcorneil
02/29/2020, 11:56 AMmboudraa
03/02/2020, 7:25 PMactionChannel.asFlow()
emit the value as expected but the second one in the side effect fow doesnt emit anything inside the zip.
Outside the zip if i subscribe multiple times to actionChannel all my subscriptions receive the value properly. But not inside the zip.
I can’t understand what’s happening tbh. I’d love some insights if possible.
ideally i’d like the actionChannel
to behave like a PublishSubjectMohamed Ibrahim
03/03/2020, 11:35 AMclass RetrieveProducts(): suspend fun () -> Flow<List<Product>> {}
Mohamed Ibrahim
03/03/2020, 11:36 AMrkeazor
03/04/2020, 10:21 PMmiqbaldc
03/06/2020, 9:32 AMObservable
-> Flow
2. `Completable`/`Single` / `Completable.defer`/`Single.defer`-> suspend fun
/ Deferred
?
3. PublishSubject
-> BroadcastChannel
?
4. Observable.merge
, Observable.compose
, Observable.mergeWith
-> Flow.zip
, Job.join
, x?
5. ObservableTransformer
, `-> ?
6. Flowable.just
-> flowOf
?
7. Flowable.flatMapPublisher
-> Flow.map
the above usecase we found from below references:
1. https://www.slideshare.net/manuelvicnt/coroutines-and-rxjava-an-asynchronicity-comparison
2. https://viseon.ch/blogs/convertRxToCoroutine/index.html
3. https://github.com/epam/CoroutinesExtensions
4. https://github.com/sys1yagi/implementation-of-async-request-with-rxjava2-or-coroutinePaul Woitaschek
03/06/2020, 11:28 AMTolriq
03/06/2020, 11:32 AMbhatnagarm
03/08/2020, 4:22 PMZach Klippenstein (he/him) [MOD]
03/10/2020, 6:09 PMOfir Bar
03/12/2020, 8:57 AMfun getCityById(selectedCityId: Int): City {
var city : City? = null
viewModelScope.launch {
city = locationRepository.getSingleCityFromDatabaseById(selectedCityId)
}
return city //Compilation error message: type mismatch, Required:City, found: City?
}
fun getListOfLanguagesByIds(selectedLanguages: List<Int>): List<Language> {
viewModelScope.launch {
return supportedLanguagesRepository.getLanguagesFromDatabaseById(selectedLanguages.toIntArray())
}// Compilation error above message: 'return' is not allowed here
}
fun getExpertiseFieldById(expertiseFieldId: Int): ExpertiseField {
lateinit var expertiseField : ExpertiseField
viewModelScope.launch {
expertiseField = expertiseFieldsRepository.getSingleExpertiseFieldFromDatabaseById(expertiseFieldId)
}
return expertiseField
//Seems to work, but I am afraid expertiseField will be returned uninitialized.
}
Slack Conversationmingkangpan
03/12/2020, 8:57 AMscope.launch(*SupervisorJob()*) {
?
in which scenario would I code this?Shawn Karber_
03/12/2020, 8:19 PMimport io.ktor.client.HttpClient
import io.ktor.client.request.*
import kotlinx.coroutines.*
/*
* List of required functions that each platform-specific code implementation needs in order
* to be compliant with this SDK.
*/
expect fun environmentMetaData(): String
/*
* Gathers relevant environment code from the device at runtime including the device details and
* operating system properties to assist in debugging, logging, and error reporting.
*
* @return: String
* a string representation of the meta data during runtime including os and device details
*/
fun gatherEnvironmentalMetaData(): String {
return environmentMetaData()
}
fun hitApi(uri: String): String {
return uri
}
fun fetcher(uri: String) = {
val client: HttpClient = HttpClient()
val content: String = async {
}
}
Mohamed Ibrahim
03/14/2020, 3:05 PM_githubService.contributors(_username!!.text.toString(), _repo!!.text.toString())
.asFlow()
.launchIn(this)
I still have the suspend function compile error in contributors
functionmyanmarking
03/17/2020, 11:16 AMmyanmarking
03/17/2020, 11:59 AMCLOVIS
03/20/2020, 1:19 PMobject Foo {
companion object {
suspend fun something(...)
}
}
When using auto completion to call Foo.something()
in a non-suspending context (so it shouldn't be possible), IDEA will expand Foo.[caret]
into Foo.Companion.something()
then the ‘Redundant Companion reference' will kick in, and after removing the Companion.
manually, only then will IDEA say ‘suspend function 'something' should be called from a coroutine [...]'
It would be much better if the message was shown during completion (eg. Type Foo.
, hit tab, see the list of functions with the suspending ones in orange with a message ‘cannot be called from outside a coroutine' or something similar).
IntelliJ Ultimate 2020.1, Kotlin 1.3.61tseisel
03/24/2020, 3:32 PMsuspend fun
are implemented: https://medium.com/androiddevelopers/the-suspend-modifier-under-the-hood-b7ce46af624f
Since each suspend fun
is compiled to a state-machine class, a project with a lot of suspending functions will generate a lot of bytecode, right ?
Does shrinking tools like Proguard succeed in reducing the size of such bytecode ?riflockle
03/24/2020, 11:44 PMandroid test
source code
// AnyTest.kt
@Test
fun callStackCrop_a() = runBlocking {
a(0)
a(1)
a(2)
a(3)
a(10)
***a(11)*** // 76 line
a(12)
}
suspend fun a(x: Int): Unit = b(x) // this action cropped....
suspend fun b(x: Int) = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
c(x) // 82 line
}
suspend fun c(x: Int) {
if (x > 10) {
throw NullPointerException("ops x = ${x} > 0") // 86 line
}
}
Test result is that
at ___.AnyTest.c(AnyTest.kt:86)
at ___.AnyTest$b$2.invokeSuspend(AnyTest.kt:82)
at |b|b|b(Coroutine boundary.|b(|b)
at ___.AnyTest$koroChase$1.invokeSuspend(AnyTest.kt:76)
Caused by: java.lang.NullPointerException: ops x = 11 > 0
at ___.AnyTest.c(AnyTest.kt:86)
at ___.AnyTest$b$2.invokeSuspend(AnyTest.kt:82)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
"Calling b() method
at a()
" is removed…..
I want to see all call stack trace
in coroutine
how to recover this call stack.....?
Attach a link with a similar problem
https://github.com/Kotlin/kotlinx.coroutines/issues/1660rrva
03/25/2020, 1:16 PM