Juanjo
08/07/2023, 9:12 AMContinuation
implementation
2. We could change the Kotlin code on suspend functions to use things like GlobalScope
to return CompletableFuture
but I’m not sure if this is the best practice (or it doesn’t look like it is for me)
Do you know what is commonly the best practice for this case? 🤔
Not sure if this is the place for the question, so let me know and I’ll move the message 🙂 . Have a great week!Peter Kievits
08/07/2023, 9:18 AMfun suspend doSomething(input: String): Output)
and wrap with fun doSomething(input:String): Single<Output> = rxSingle { wrapped.doSomething(input) }
. Although Rx might not be how you want to expose your API, it does provide a java friendly way to handle this.Peter Kievits
08/07/2023, 9:24 AMJuanjo
08/07/2023, 9:26 AMPeter Kievits
08/07/2023, 9:27 AMPeter Kievits
08/07/2023, 9:28 AMJuanjo
08/07/2023, 9:52 AMEdoardo Luppi
08/07/2023, 10:03 AMexpect class MyDeferred<T>
// JS
actual typealias MyDeferred<T> = Promise<T>
// JVM
actual typealias MyDeferred<T> = CompletableFuture<T>
Then, the service proxy (a wrapper for the internal suspending service) uses
// JS
CoroutineScope.promise()
// JVM
CoroutineScope.future()
This allow working on common code for the most part, having a single MyDeferred
type for all platform. You can use extension functions to add stuff to MyDeferred
.Edoardo Luppi
08/07/2023, 10:03 AMEdoardo Luppi
08/07/2023, 10:07 AMEdoardo Luppi
08/07/2023, 10:13 AMMyDeferred
a wrapper class. I think I'll move to that directionEdoardo Luppi
08/07/2023, 3:18 PMJuanjo
08/07/2023, 4:13 PMJuanjo
08/10/2023, 8:33 AMPeter Kievits
08/10/2023, 8:44 AMJuanjo
08/10/2023, 8:52 AMPeter Kievits
08/10/2023, 8:55 AMPeter Kievits
08/10/2023, 8:55 AMJuanjo
08/10/2023, 8:58 AMJuanjo
08/10/2023, 9:00 AMPeter Kievits
08/10/2023, 9:00 AMJuanjo
08/10/2023, 9:00 AMPeter Kievits
08/10/2023, 9:00 AMJuanjo
08/10/2023, 10:54 AMPeter Kievits
08/10/2023, 10:56 AMJuanjo
08/10/2023, 10:56 AMPeter Kievits
08/10/2023, 12:10 PMPeter Kievits
08/10/2023, 12:10 PMJuanjo
08/11/2023, 9:57 AMPeter Kievits
08/11/2023, 12:39 PMPeter Kievits
08/11/2023, 12:40 PMPeter Kievits
08/11/2023, 12:41 PMJuanjo
08/11/2023, 12:42 PMPeter Kievits
08/11/2023, 2:08 PMJuanjo
08/11/2023, 2:09 PMJuanjo
08/11/2023, 2:10 PMEdoardo Luppi
08/11/2023, 2:12 PMPeter Kievits
08/11/2023, 2:13 PMPeter Kievits
08/11/2023, 2:14 PMJuanjo
08/11/2023, 2:14 PMJuanjo
08/11/2023, 2:15 PM/gradlew build
in the applied projectJuanjo
08/11/2023, 2:15 PMEdoardo Luppi
08/11/2023, 2:16 PMoh the code generation happens in the project where it’s usedThat possibly means a common annotation to generate a
Promise
wrapper (yet again with KPoet) is doable?Juanjo
08/11/2023, 2:17 PMJuanjo
08/16/2023, 2:17 PMPeter Kievits
08/18/2023, 10:48 AMPeter Kievits
08/18/2023, 10:48 AMPeter Kievits
08/18/2023, 10:49 AMPeter Kievits
08/18/2023, 10:57 AMPeter Kievits
08/18/2023, 10:57 AMJuanjo
08/18/2023, 1:12 PMPeter Kievits
08/18/2023, 2:02 PMJuanjo
08/18/2023, 2:34 PMPeter Kievits
08/18/2023, 2:53 PMJuanjo
08/28/2023, 11:02 AMJuanjo
08/28/2023, 3:09 PMPeter Kievits
08/29/2023, 7:38 AM