withoutclass
09/06/2018, 3:07 PMcoroutineContext
with withContext
?v0ldem0rt
09/06/2018, 6:12 PMAtmoic*
matt tighe
09/06/2018, 6:13 PMfun refreshData() {
networkStatus = Status.ACTIVE // class member
launch(CommonPool) {
asyncAwait {
remoteSource.fetchData().forEach {
roomDatabase.dao().insertData(it)
}
networkStatus = Status.INACTIVE
}
}
}
i’d like to be able to unit test that the status is updated while the coroutine is runningiLobanov
09/07/2018, 4:40 AMfun someFunction() : SomeResult {
val someObj = SomeObj(SomeListenr { result ->
SomeResult(result) // <- WANT THIS
}
)
someObj.start()
}
Paul Woitaschek
09/07/2018, 3:17 PMdata class Person(val userName : String, age : Int)
Paul Woitaschek
09/07/2018, 3:55 PMincreasePortionCount
does not emitbj0
09/08/2018, 7:20 AMlaunch(coroutineContext +IO) { channel.consumeEach { ... } }
. I feed the channel from another coroutine that runs every 15s, and in the consumeEach
i do a network send (through a cpp library). This works fine for a couple minutes but eventually this coroutine stops executing and the cpu usage of the process goes from .02% to 70%. This is on a desktop. If I remove the IO
and use the CommonPool
it works fine. There are no errors or exceptions, the coroutine just stops and the cpu goes nuts. Is there anything I can do to try and figure out whats happening?napperley
09/09/2018, 6:47 AMfreddiewang
09/11/2018, 3:48 AMsuspendCoroutineUninterceptedOrReturn
or intercepted
is generated in coroutine library? I’m confused about why some core functions are auto-gen… Any specific reason?freddiewang
09/11/2018, 4:38 AMdstarcev
09/11/2018, 10:18 AMsomeFlux.forEach {
val result = callAnotherSuspendingFunction(it)
doSomethingElse(result)
}
Joe
09/11/2018, 3:33 PMlaunch(UI)
in it, but I'm getting the following message
java.lang.NoClassDefFoundError: Could not initialize class kotlinx.coroutines.experimental.android.HandlerContextKt
alexcouch
09/12/2018, 4:54 AMDaniel Tam
09/12/2018, 12:45 PMlouiscad
09/12/2018, 2:01 PMcoroutineScope
extensions for Lifecycle
and LifecycleOwner
(that you can use in AppCompatActivities, Fragments, LifecycleServices...) for changes in kotlinx.coroutines 0.26.0: https://gist.github.com/LouisCAD/58d3017eedb60ce00721cb32a461980f#file-lifecyclejob-kt-L30Jonathan
09/12/2018, 2:06 PMawaitAll(one, two)
by one.await(); two.await()
in this code?dekans
09/12/2018, 2:24 PMJob
that I used as a parent for coroutines in this class. At some point I did a job.join()
to make sure all operations were over.
Now, I made this class implement CoroutineScope
, I run some operations in launch(Dispatchers.Main+job)
But job.join()
is not effective anymore, and I cannot use coroutineContext[Job]
for it.
How should I do to have a 'global' Job
which I could use?Jonathan
09/12/2018, 2:55 PMJavaFx
dispatcher not an extension property on Dispatchers
?StevieB
09/12/2018, 3:44 PMjw
09/12/2018, 8:06 PMDias
09/12/2018, 8:15 PMDias
09/12/2018, 8:16 PMgotoOla
09/13/2018, 7:50 AMpoohbar
09/13/2018, 12:42 PMUnfortunately, this example is wrong on many levels in very subtle ways.Seriously? So all these talks were full of completely wrong examples? And you just found out? It's not like these concepts are completely new to computer science, why not take more inspiration from other languages such as
clojure.async
?Бежан Александр
09/13/2018, 3:44 PMava.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
app/Main$main$1$1.doResume(Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object; @1347: invokespecial
Reason:
Type 'java/util/Collection' (current frame, stack[2]) is not assignable to 'app/Main$main$1$1$doResume$$inlined$run$lambda$1'
rocketraman
09/13/2018, 5:31 PMnewSingleThreadContext
and was passing that to launch
. Is the right way to do this to now create a CoroutineScope
that encapsulates that dispatcher, and then call launch
with that scope?enleur
09/14/2018, 5:17 AM<http://Dispatchers.IO|Dispatchers.IO>
, now it cuts unused threads instant, but consumes more cpuaaverin
09/14/2018, 2:51 PMfun setup() {
if (!requiresMigration()) {
launch { regularPaymentSetup.setup() }
} else {
launch { migrationPaymentSetup.setup(it) }
}
}
How to unit-test that regularPayment is executed?
launch
starts a new coroutine and test failsbj0
09/14/2018, 4:53 PMmarcinmoskala
09/14/2018, 6:46 PMmarcinmoskala
09/14/2018, 6:46 PMvoddan
09/14/2018, 7:36 PMmarcinmoskala
09/14/2018, 7:45 PMclass UI: KTKotlinx_coroutines_core_nativeCoroutineDispatcher {
override func dispatch(context: KTStdlibCoroutineContext, block: KTKotlinx_coroutines_core_nativeRunnable) {
DispatchQueue.main.async {
block.run()
}
}
}