gildor
11/15/2017, 8:15 AMgildor
11/15/2017, 8:15 AMgildor
11/15/2017, 8:15 AMgildor
11/15/2017, 8:16 AMsailxjx
11/15/2017, 8:17 AMgildor
11/15/2017, 8:17 AMgildor
11/15/2017, 8:18 AMgildor
11/15/2017, 8:18 AMgildor
11/15/2017, 8:20 AMsailxjx
11/15/2017, 8:21 AMgildor
11/15/2017, 8:22 AMgildor
11/15/2017, 8:23 AMsailxjx
11/15/2017, 8:25 AMgildor
11/15/2017, 8:27 AMsailxjx
11/15/2017, 8:28 AMgildor
11/15/2017, 8:31 AMsailxjx
11/15/2017, 8:38 AMgildor
11/15/2017, 8:43 AMwhile(true)
that checks queue size with or without delaydave08
11/15/2017, 9:52 AMproduce { }
, you can give it a buffer size, and when full, it will suspend the message requesting until its consumer is ready to receive more, so all you need is a simple consumeEach{}
on the producer to process the messages...sailxjx
11/15/2017, 10:35 AMuli
11/15/2017, 8:18 PMdave08
11/15/2017, 8:35 PMproduce {}
is backed by a Channel, from the original code it looks like needs to make multiple calls to an API and have to handle them downstream with back pressure, but upstream doesn't need that. I think a Channel should be avoided just like an rx Subject, when produce
is enough... Unless I'm misunderstanding something?uliluckas
11/15/2017, 8:39 PMproduce
from multiple API callsuliluckas
11/15/2017, 8:40 PMuliluckas
11/15/2017, 8:41 PMproduce
is enough, I agree with @dave08. Then go with produce
dave08
11/15/2017, 9:23 PMfun getTopics() = buildSequence {
yield(kafka.getTopic()) // This suspends until next value is requested
}
But then there's no buffer... You might be right @uli...julienviet
11/15/2017, 9:27 PMleosan
11/16/2017, 4:29 PMlaunch(CommonPool) {
withLoading(view.show,view.hide) // <<-
val result = ApiClient.getSomething().awaitResult()
doSomethingWithResult(result)
}
I'd like to compose this withLoading()
method in a way that it executes the view.show()
at the start of the parentCouroutine and the view.hide()
only after the api call
with the awaitResult()
finishes, but I'm struggling to undestand/do this 😞 any help is very welcomeleosan
11/16/2017, 4:32 PMlaunch(CommonPool) {
view.show()
val result = ApiClient.getSomething().awaitResult()
doSomethingWithResult(result)
view.hide()
}
and it works just fine, but I would like to abstract this to avoid writing this show/hide every timedave08
11/16/2017, 4:47 PMinline fun withLoading(before: () -> Unit, after: () -> Unit, block: suspend () -> Unit) { before(); block(); after(); }
Then run like this:
withLoading(view::show, view::hide) { ... }
I think that should do it?