Slackbot
08/29/2018, 4:28 PMSeri
08/29/2018, 5:24 PMaaverin
08/29/2018, 6:54 PMaaverin
08/29/2018, 7:33 PMblockingProduce
? I have an async callback that I want to wrap into a channelbdawg.io
08/30/2018, 2:50 AMsvenjacobs
08/30/2018, 1:33 PMotakusenpai
08/30/2018, 2:33 PMaaverin
08/30/2018, 7:01 PModay
08/30/2018, 7:05 PMcarsService
object have already went outrocketraman
08/30/2018, 9:05 PMretry
function that takes an action
lambda. Is there a way for me to define this function in such a way that the action
lambda can be either suspending or non-suspending depending on the caller?IRomanov
08/30/2018, 9:49 PMasync
coroutine builder to execute some blocking code in parallel. I use my custom thread pool for that. But is it ok to call regular (non-suspending) function inside async
?
fun doSomething(s: String): String {
// blocking code
}
val def1 = async(myContext) { doSomething("a") }
val def2 = async(myContext) { doSomething("b") }
// ...
println("${def1.await()} ${def2.await()}")
Albert
08/31/2018, 8:03 AMval dispatcher = Executors.newFixedThreadPool(64).asCoroutineDispatcher()
runBlocking(dispatcher) {
launch {
// do something
}
}
I thought launch
in the example would automatically inherit the dispatcher
, but I see launch
uses the CommonPool
if it is implemented like this. Is there a way that this automatically inherits the parents dispatcher or should it always be used like this launch(coroutineContext)
?ylemoigne
08/31/2018, 9:44 AM> Could not parse module metadata <https://jcenter.bintray.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/0.25.0/kotlinx-coroutines-core-0.25.0.module>
> Unsupported format version '0.3' specified in module metadata. This version of Gradle supports format version 0.4 only.
richodemus
08/31/2018, 1:59 PMpdegand
08/31/2018, 3:20 PMreceive()
, some code that will send stuff into the channel is executedNikky
09/02/2018, 11:24 AMval targetFiles = Collections.synchronizedMap(mutableMapOf<String, File>())
val features = Collections.synchronizedList(mutableListOf<SKFeatureComposite>())
val jobs = mutableListOf<Job>()
for(...) {
jobs += launch {
//do work here
targetFile[id] = someFIle
if(feature != null) {
features += feature
}
}
}
jobs.forEach { it.join() }
is there cleaner ways to handle collecting data that lets me juggle less mutable collections ?khairil.ushan
09/02/2018, 5:04 PMsearch
function after user finish typing (by being idle for >=400ms). is this the correct way to do this with coroutines?
fun onKeywordChanged(keyword: String) {
keywordJob.cancel()
keywordJob = launch {
delay(400)
if (!isActive) return@launch
search(keyword)
}
}
Aregev2
09/02/2018, 6:22 PMcompile "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.25.0-eap13"
This is correct, right?Nikky
09/03/2018, 1:04 AMNikky
09/03/2018, 11:22 AMvitrox1
09/04/2018, 1:03 PMsdeleuze
09/04/2018, 2:22 PMkotlinx.coroutines
EAP in order to avoid the pre-release warnings with Kotlin 1.3-M2?egorand
09/04/2018, 3:00 PMsuspend
is a breaking change, since the callers now have to wrap it inside a coroutine builder. Ideally I'd like library users to opt into coroutines if they decide to and be able to use the library as is if they don't, and avoid duplicating code add coroutines support. Any OS projects that do this already?Allan Wang
09/04/2018, 4:07 PMrocketraman
09/04/2018, 4:36 PMGabriel Ittner
09/04/2018, 6:34 PM0.25.3-eap13
?thevery
09/05/2018, 8:29 AMilya.gorbunov
09/05/2018, 11:41 AMrichodemus
09/05/2018, 2:49 PMdelay
so like this:
launch {
println("This is called right away")
delay(1, YEARS)
println("I want this to happen when a criteria is met")
}
if(criteria) {
cancelDelay()
}
aaverin
09/05/2018, 3:12 PMaaverin
09/05/2018, 3:12 PMSeri
09/05/2018, 3:17 PMPaul Woitaschek
09/05/2018, 3:24 PMPublishSubject
?louiscad
09/05/2018, 4:08 PMSuccessOrFailure
through a channel. Otherwise, a sealed class or similar would be greatuli
09/05/2018, 6:26 PMaaverin
09/06/2018, 11:00 AMproduce
– I am wrapping a 3rd party library callback.
So I have a channel, and callback, that will be invoked some time in the future, and might have error inside. If it happens, I need to inform my channel subscriber that something went wrongonError()
?Paul Woitaschek
09/06/2018, 11:07 AMaaverin
09/06/2018, 11:07 AMPaul Woitaschek
09/06/2018, 11:08 AMaaverin
09/06/2018, 11:09 AMsealed class PurchaseEvent {
object Success : PurchaseEvent()
data class Error(val reason: String) : PurchaseEvent()
}
@Singleton
internal class ChanneledPurchaseHandler @Inject constructor() {
val purchaseHandler = object : PurchaseHandler {
override fun onPurchaseSuccess() {
launch { channel.send(PurchaseEvent.Success) }
}
override fun onPurchaseFailure(errorCode: Int, errorMessage: String?) {
launch { channel.send(PurchaseEvent.Error("$errorCode $errorMessage")) }
}
}
val channel = BroadcastChannel<PurchaseEvent>(1)
}
send
to sendBlocking
and test was easylouiscad
09/06/2018, 3:51 PM