EdricChan03 / EdricChan03/Koogle-API

[All] Provide Java equivalents of Kotlin coroutines/Flows

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
affects:java api request design enhancement
Dominant language
Kotlin
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

See #8

> Calling `suspend` functions is impossible from Java as the [`Continuation` interface appears to expect a `sealed` class that has an `internal` Kotlin class](https://stackoverflow.com/questions/52869672/call-kotlin-suspend-function-in-java-class)

## API suggestions

(Suggestions are tentative as of now)

### For single-value `suspend` functions

We could expose methods that return one of the following:

Object | Source | Implementation
---|---|---
[`CompletableFuture`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html) | Java 8+ | [`CoroutineScope#future`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.future/future.html)
[`ListenableFuture`](https://guava.dev/releases/snapshot/api/docs/com/google/common/util/concurrent/ListenableFuture.html) | [Guava](https://guava.dev) | [`CoroutineScope#future`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-guava/kotlinx.coroutines.guava/future.html)
[`Single`](https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Single.html) | [RxJava](https://github.com/ReactiveX/RxJava) 2.x | [`rxSingle`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-single.html)
[`Single`](https://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Single.html) | [RxJava](https://github.com/ReactiveX/RxJava) 3.x | [`rxSingle`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-rx3/kotlinx.coroutines.rx3/rx-single.html)

### For methods that return a `Flow`

We could expose methods that return one of the following:

Object | Source | Implementation
---|---|---
[`Flow.Publisher`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/Flow.Publisher.html) | Java 9+ | [`Flow.asPublisher`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-jdk9/kotlinx.coroutines.jdk9/as-publisher.html)
[`Flowable`](https://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html) | [RxJava](https://github.com/ReactiveX/RxJava) 2.x | [`Flow.asFlowable`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/as-flowable.html)
[`Flowable`](https://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html) | [RxJava](https://github.com/ReactiveX/RxJava) 3.x | [`Flow.asFlowable`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-rx3/kotlinx.coroutines.rx3/as-flowable.html)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.