question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flow support for Kotlin coroutines

See original GitHub issue

Hello,

I think it would be great to have something like this for coroutines collection.find().toFlow()

There is consumeEach method in CoroutinePublisher, but I think Flow can be more powerful

Maybe something like this with closing resources on cancel

flow {
            collection.find()
                .consumeEach {
                    emit(it)
                }
        }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
zigzagocommented, May 15, 2020

Thank you for this PR! 😃 I will look at it soon. The <T:Any> is a common problem in kotlin because T alone is equivalent to T:Any?. So:

class A<T:Any>(val a:T)
class B<T:Any?>(val b:T)
class C<T>(val c:T)

fun main() {
    A(null) //compile error
    B(null) //ok
    C(null) //ok
}

I suspect that KMongo is wrong here, I will investigate the problem when looking at your PR 😉

0reactions
sausageRollcommented, May 13, 2020

Hey

I opened a PR for that issue please check it out when you have time https://github.com/Litote/kmongo/pull/202

I don’t know how adding <T :Any> to all types will affect current clients of the library. For me it looks like anyway it’s impossible to create …Publisher with T?

So what do you think about that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learn advanced coroutines with Kotlin Flow and LiveData
In this codelab, you'll learn how to use the LiveData builder to combine Kotlin coroutines with LiveData in an Android app.
Read more >
Asynchronous Flow - Kotlin
The collection works directly in the coroutine that calls a terminal operator. No new coroutines are launched by default. Each emitted value is ......
Read more >
Kotlin Coroutines Flow in a nutshell - ProAndroidDev
Each Flow chain consists of a specific set of operators. Each operator creates a new Flow instance but at the same time stores...
Read more >
Going Reactive with Spring, Coroutines and Kotlin Flow
Kotlin was announced as an official Android development language at Google I/O 2017, we continued to improve the Kotlin support across Spring ...
Read more >
Kotlin Flows and Coroutines - Roman Elizarov - Medium
Indeed, the design of Kotlin Flows is based on suspending functions and they are completely sequential, while a coroutine is an instance of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found