zak.taccardi
04/08/2019, 6:14 PMCoroutineScope
?louiscad
04/08/2019, 7:44 PMsuspend fun <T> raceOf(vararg racers: suspend CoroutineScope.() -> T): T = coroutineScope {
select<T> {
@UseExperimental(ExperimentalCoroutinesApi::class)
val racersAsyncList = racers.map { async(start = CoroutineStart.UNDISPATCHED, block = it) }
racersAsyncList.forEach { racer ->
racer.onAwait { resultOfWinner ->
racersAsyncList.forEach { deferred -> deferred.cancel() }
return@onAwait resultOfWinner
}
}
}
}
serebit
04/08/2019, 7:57 PMBroadcastChannel<Unit>
on the top level. Every channel will call subscribe and receive on this channel at the start of processing a request. The variable will usually be null, but if a “global” header is received, it will be set to BroadcastChannel(1)
, and the channel where this header was received will delay for the given amount of time before setting the variable to null and calling send(Unit)
, unsuspending all the waiting channels.
Solution 2️⃣ Hold the global delay target as a unix millis, or null, at the top level. Every channel will delay for the amount it time it takes to get to that unix millis if it is not null. If a channel receives the global header, it sets the global unix millis and delays for that period of time before setting it back to null.Sam
04/08/2019, 10:01 PMbloder
04/09/2019, 2:32 AMasync
is not working (newbie question probably)sdeleuze
04/09/2019, 9:19 AMFlow
for hot streams as well like where we use Flux
or Flowable
for these use cases? If yes what are the pros/cons compared to channels?jakub.dyszkiewicz
04/09/2019, 12:06 PM.sample(Duration)
?
https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#sample-java.time.Duration- on channel. I’d like to throttle consumer of channel to process the latest data not often than every 1sv0ldem0rt
04/09/2019, 4:06 PMv0ldem0rt
04/09/2019, 4:08 PMRobert Jaros
04/09/2019, 5:25 PMrrva
04/09/2019, 5:27 PMwrover
04/10/2019, 6:51 AMContinuation#invokeOnCancellation
from suspendCancellableCoroutine
but, obviously, it doesn't work this way.sdeleuze
04/10/2019, 8:02 AMsuspend fun <T : Any> RowsFetchSpec<T>.awaitOne(): T = one().awaitSingle()
but when it used, type inference shows T!
, what did I miss? I have specified that T
extends non nullable Any
so I would expect return type T
.Olekss
04/10/2019, 12:52 PMazeDevs
04/10/2019, 1:03 PMoshai
04/10/2019, 2:27 PMigorvd
04/10/2019, 6:35 PMdelays
from coroutines in android espresso testing?dewildte
04/10/2019, 7:08 PMBrandon Trautmann
04/11/2019, 1:42 AMDariusz Kuc
04/11/2019, 5:54 AMby lazy
. I'm migrating now to coroutines was wondering whats the proper way to update by lazy
to call suspendable function. Any thoughts on how to make this better?Robert Jaros
04/11/2019, 8:18 AMGarouDan
04/11/2019, 11:24 AMStephane M
04/11/2019, 11:51 AMList<Node>
. I want to run a repeated background job on each node in that list (independently), that fetches some data from a URL and mutates the node state at each iteration. At some point I want to be able to stop the entire job altogether. Do you have any pointers? I'm a bit lost with coroutinesMarko Mitic
04/11/2019, 4:30 PMobobo
04/11/2019, 4:35 PMpardom
04/11/2019, 4:58 PMigorvd
04/11/2019, 6:18 PMFlow
? I was looking at the onErrorCollect
and onErrorReturn
but I'm not sure how to use it. I'm using the simple try-catch
now, but I was wondering if it already has an API for that.
My usecase is that I'm trying to write an offline-first approach: I first search on local storage and emit what it has, then I look online and emit the itens that aren't cached yet . I want to handle the exceptions (mostly networking ones) only if the local storage was empty in the first place.nulldev
04/12/2019, 9:32 AMval job = launch(Dispatchers.Default) {
val result = myGiantList.asFlow().filter {
cpuBoundFilter(it)
}.toList()
}
job.cancel()
If I don't do any cancellation checks in cpuBoundFilter
, the flow will continue to filter through everything even though it has been cancelled.zak.taccardi
04/12/2019, 4:58 PMactor.offer(message)
(instead of actor.send(message)
when the actor(capacity = Channel.UNLIMITED)
, is there locking involved?Vsevolod Tolstopyatov [JB]
04/12/2019, 6:31 PMkotlinx.coroutines
1.2.0 is here!
Changelog:
* Kotlin 1.3.30
* New API: CancellableContinuation.resume
with onCancelling
lambda to consistently handle closeable resources.
* Flow improvements, including new operators, better documentation and RxJava integration. Note that it is not leaving its experimental status yet.
Full changelog: https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.2.0Vsevolod Tolstopyatov [JB]
04/12/2019, 6:31 PMkotlinx.coroutines
1.2.0 is here!
Changelog:
* Kotlin 1.3.30
* New API: CancellableContinuation.resume
with onCancelling
lambda to consistently handle closeable resources.
* Flow improvements, including new operators, better documentation and RxJava integration. Note that it is not leaving its experimental status yet.
Full changelog: https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.2.0sdeleuze
04/12/2019, 8:19 PMelizarov
04/13/2019, 7:42 AMflatMap
is expected to do (should it concat or merge), so this way we can defer making this decision.sdeleuze
04/25/2019, 1:32 PMconcatMap
instead of flatMapConcat
and flatMap
instead of flatMapMerge
?elizarov
04/25/2019, 5:46 PMflatMap
should do flatMapMerge
. The downside of that decision is that if you copy-and-paste a code written with Sequence
to Flow
then suddenly it starts working differently, because flatMap
for sequences is flatMapConcat
.