hmole
06/26/2019, 5:09 AMCoroutineScope
receiver). Is there a better way? Sample in a thread.pawelbochenski
06/26/2019, 6:35 AMYan Pujante
06/26/2019, 4:08 PMAlexander Vtyurin
06/26/2019, 8:03 PMwhile
loop instead of this?
while (condition) {
...
delay(1)
}
jw
06/27/2019, 2:15 PMdoSomething()
directlyPaul Woitaschek
06/28/2019, 9:27 AM<T> Observable<T> merge(Iterable<? extends ObservableSource<? extends T>> sources)
?Dias
06/28/2019, 1:34 PMharoldadmin
06/28/2019, 5:22 PMCoroutine Scope
interface in it? There will be no lifecycle callback to cancel the running coroutines in this scope, though. Since a single instance of this class will be shared with the entire application, any coroutines launched in this scope will be equivalent to launching them in the global scope. So should I just avoid the ceremony and use GlobalScope in this class?ursus
06/28/2019, 7:05 PMLuis Munoz
06/28/2019, 9:57 PMgroostav
06/28/2019, 11:51 PM@guava.Subscribe suspend fun handle(event: MyEvent)
functions, but by default guava has no idea how to handle that.
I've tried:
1. switching my tests to invoke handlers directly. This works for tests but has trouble with some of our components
2. adding an obnoxious inheritance system to try and keep a List<Job>
on the event itself, that gets appended to by subscribers. This is not great.
I'd be willing to take a fork of evenBus just for support for concurrent & synchronous event publication, especially if I can get it without retrofitting existing blocking java code.Paul Woitaschek
07/01/2019, 8:58 PMclass Subject(val scope: CoroutineScope) {
fun foo() {
scope.launch {
// launch uses the testScope injected in setup
}
}
}
But what do I actually pass in production code here?streetsofboston
07/01/2019, 10:22 PMgeorgiy.shur
07/02/2019, 5:35 AMstreetsofboston
07/02/2019, 3:04 PMSupervisorJob
.
This code
CoroutineScope(SupervisorJob()).launch {
launch {
println("Launched Child 1")
delay(500)
println("Child 1 crashed")
throw SillyException()
}
launch {
println("Launched Child 2")
delay(1000)
println("Child 2 is still running")
delay(500)
}
delay(1000)
println("Parent is still running")
}
Thread.sleep(2000)
prints out this:
Launched Child 1
Launched Child 2
Child 1 crashed
Exception in thread "DefaultDispatcher-worker-2 @coroutine#3" launch_exceptions.SillyException: Silly
at launch_exceptions.FileKt$main$1$1.invokeSuspend(File.kt:20)
...
I expected only “Child 1” to crash/stop, due to the parent being a Supervisor-Job .
However, I expected “Child 2" launch and the parent to continue running…
especially since MainScope()
is defined in a similar way…necati
07/02/2019, 5:48 PMObservable.interval(0, 1, TimeUnit.MINUTES)
When I leave the page, the task should be dismissed.
Any suggestions?kevin.cianfarini
07/02/2019, 7:55 PMFlow
instead of LiveData
? I'd like to use flow for everything but I don't know of any catches that Flow may have since I'm pretty inexperienced with it.ursus
07/03/2019, 8:47 AMgroostav
07/03/2019, 6:46 PMSequence
that work for suspend
contexts? IE i have a sequence and I want to map
on it in a suspend
callerrook
07/03/2019, 8:31 PMJob
join()
asynchronously? I’d like to append coroutines to a job dynamically and then have it complete when it runs out of running coroutinesbj0
07/04/2019, 1:07 AMChannel operators are deprecated in favour of Flow and will be removed in 1.4But if my channel source is hot (network traffic), how/where should I introduce Flow? The articles I've read so far make the distinction between hot and cold data streams and claim Flow is for cold streams
rkeazor
07/04/2019, 2:16 AMSlackbot
07/04/2019, 3:54 AMpteale
07/04/2019, 1:47 PMreturn async {
val newConsent = consent.copy(createdAt = getConsent()?.createdAt)
val uniqueId = getUniqueId().await()
val consentFromApi = userServiceApi.consentApiClient.putConsent(uniqueId, newConsent).await()
localStorageService.setConsent(consentFromApi)
}
Which should return a Deferred<Unit>koufa
07/05/2019, 1:53 PMflow
. I want to listen to text changes from an input field. The classic way would be to add a listener to the input field and respond to text changes in the callback. Now I want to get a flow
which emits the current text on every text change. Do I need to use a channel
that sends the text on every text change and then create a flow from the channel? I saw that there are some APIs for that on the flow documentation pages.Luis Munoz
07/05/2019, 5:10 PMPere Casafont
07/08/2019, 11:25 AMsuspend
modifier to a function that I know it will take long to compute, intellij bugs me with the Redundant 'suspend' modifier
inspection. Am I doing something wrong? All I want is to force this function to be called from a coroutine scope...addamsson
07/08/2019, 12:33 PMLuis Munoz
07/08/2019, 4:20 PMMarcelo Hernandez
07/08/2019, 5:16 PMSingles
, Maybes
, and Completables
to suspend
functions. I feel that with Rx, error handling is pretty much try/catch(Throwable)
behind the scenes. So when switching over to coroutines, one might "naively" start using runCatching { ... }.onSuccess { ... }.onFailure { ... }
or basic try/catch(Throwable)
. The issue with this is that a CancellationException
will also be caught when attempting to cancel a coroutine. Does this mean that before refactoring to suspend
functions, one should begin defining custom, domain-specific Exceptions or leverage some sort of Result
type in order to avoid try/catch(Throwable)
?Marcelo Hernandez
07/08/2019, 5:16 PMSingles
, Maybes
, and Completables
to suspend
functions. I feel that with Rx, error handling is pretty much try/catch(Throwable)
behind the scenes. So when switching over to coroutines, one might "naively" start using runCatching { ... }.onSuccess { ... }.onFailure { ... }
or basic try/catch(Throwable)
. The issue with this is that a CancellationException
will also be caught when attempting to cancel a coroutine. Does this mean that before refactoring to suspend
functions, one should begin defining custom, domain-specific Exceptions or leverage some sort of Result
type in order to avoid try/catch(Throwable)
?louiscad
07/08/2019, 6:33 PMcatch(ignored: CancellationException)
first, or from which you rethrow (important if there's only custom suspending functions that don't check for cancellation). Another is to catch only the expected exceptions (might be risky if you don't know what can be thrown). You can also check e is CancellationException
and rethrow it.Marcelo Hernandez
07/08/2019, 6:46 PMdoRxAsyncWork()
.subscribeOn(...)
.observeOn(...)
.subscribe(
{ ... },
{ error -> // perform error handling }
)
to
try {
doSuspendingWork()
} catch (ex: CancellationException) {
throw ex
} catch (ex: Throwable) {
// perform error handling
}
runCatching
utility that catches and re-throws the CancellationException
.streetsofboston
07/08/2019, 7:30 PMException
, or Throwable
, etc. In this case it is somewhat forced on you to catch specific ones onlyMarcelo Hernandez
07/08/2019, 7:37 PMObservable
Rx code to suspend
functions with minimal effort.Paul Woitaschek
07/08/2019, 8:08 PMMarcelo Hernandez
07/14/2019, 8:16 PMFlows
will be getting a catch
operator that properly handles CancellationExceptions
.
“Exceptions in Kotlin Flows” by Roman Elizarov https://link.medium.com/AenSuqlckYrunCatching
variant for non-Flow
suspend
code that also takes CancellationExceptions
into account?Stephane Maldini
07/15/2019, 10:07 PM