rocketraman
11/12/2018, 10:33 PMlouiscad
11/12/2018, 11:02 PMCoroutineScope(coroutineContext).apply { … }
thenrocketraman
11/12/2018, 11:07 PMrun
instead of apply
). Can you explain why?gildor
11/12/2018, 11:13 PMgildor
11/12/2018, 11:14 PMgildor
11/12/2018, 11:14 PMrocketraman
11/12/2018, 11:16 PMcoroutineScope
indicates:
The provided scope inherits its [coroutineContext] CoroutineScope.coroutineContext] from the outer scopeI'm just trying to understand why it does not in this case?
gildor
11/12/2018, 11:19 PMrocketraman
11/12/2018, 11:20 PMgildor
11/12/2018, 11:20 PMrocketraman
11/12/2018, 11:21 PMrxFlowable
in kotlinx-coroutines-rx2 1.0.0 is an extension of CoroutineScope
gildor
11/12/2018, 11:21 PMgildor
11/12/2018, 11:22 PMgildor
11/12/2018, 11:22 PMrocketraman
11/12/2018, 11:23 PMcoroutineScope
parent should suspend until the rxFlowable
coroutine is done, shouldn't it? That's exactly what I want...rocketraman
11/12/2018, 11:24 PMgildor
11/12/2018, 11:24 PMrocketraman
11/12/2018, 11:25 PMgildor
11/12/2018, 11:26 PMrocketraman
11/12/2018, 11:27 PMrxFlowable
to start, which it never will because we're suspended... Tricky.gildor
11/12/2018, 11:27 PMrocketraman
11/12/2018, 11:28 PMgildor
11/12/2018, 11:29 PMgildor
11/12/2018, 11:29 PMrocketraman
11/12/2018, 11:30 PMrocketraman
11/12/2018, 11:31 PMCoroutineScope(...)
don't really explain why one would use that instead of coroutineScope { ... }
either.gildor
11/12/2018, 11:32 PMgildor
11/12/2018, 11:32 PMgildor
11/12/2018, 11:33 PMrocketraman
11/12/2018, 11:33 PMgildor
11/12/2018, 11:34 PMgildor
11/12/2018, 11:35 PMrocketraman
11/12/2018, 11:35 PMrocketraman
11/12/2018, 11:36 PMCoroutineScope
so it would automatically get the parent scope. Its just that it is already extending something else so in this case I wasn't able to do that.gildor
11/12/2018, 11:36 PMrocketraman
11/12/2018, 11:37 PMgildor
11/12/2018, 11:38 PMgildor
11/12/2018, 11:39 PMgildor
11/12/2018, 11:40 PMrocketraman
11/12/2018, 11:41 PMrocketraman
11/12/2018, 11:46 PMrocketraman
11/12/2018, 11:51 PMCoroutineScope.rxFlowable
default its context to EmptyCoroutineContext
instead of the context of the scope receiver?gildor
11/13/2018, 12:41 AMgildor
11/13/2018, 2:02 AMsuspend
? It doesn’t look that you have any suspend functrions call inside, also if you migrated to CoroutineScope as receiver it’s now safe and possible to call this function from standard functiongildor
11/13/2018, 2:16 AMGlobalScope.rxFlowable
which creates global flowable, so will be exactly how Rx works.
Solution with CoroutineScope is little bit different because explicitly attaches created flowable’s lifecycle to coroutine scope, so rx now managed by the same scope and requires scope to be created, so it’s becoming Structured concurrency for Rxrocketraman
11/13/2018, 7:00 AMsuspend
isn't needed any more... it was when I was using creating a CoroutineScope with the coroutineContext
of the suspend function.