Alma
Alma

Reputation: 95

Kotlin Flow in Java

I have been trying to find some good resources that point to Kotlin Flow usage/integration in java applications but I couldn't find any. Can we use Kotlin Flow (SharedFlow/StateFlow) in Kotlin based applications that might be integrated in other Java based projects.

Upvotes: 3

Views: 4524

Answers (1)

Louis Wasserman
Louis Wasserman

Reputation: 198093

Technically, you can use any Kotlin APIs from Java, including flows and coroutines.

In practice, any attempt to use Flows directly from Java is likely to be so difficult to do correctly that you shouldn't bother trying. So don't. Instead, write Kotlin APIs that expose a non-coroutine API and wrap flows, and then use those from Java if you must.

Upvotes: 5

Related Questions