![]() ![]() That means, that the second flow is not blocked from being collected. For example like this: coroutineScope.launch ) and this new child coroutine is the one, that will be suspended. The practical difference then is, that you can call collect() method only from another suspending function or from a coroutine. launchIn() is not: public suspend fun collect(collector: FlowCollector) public fun Flow.launchIn(scope: CoroutineScope): Job Obvious differencesįor one, if we take a look at method signatures of these two methods, we’ll learn, that. There are some obvious ones and one is very subtle, not immediately obvious to everyone and you should pay attention to it, if you want your code to behave as expected. What are the differences between these two methods? (For the purposes of this article we avoid other terminal operators such as. Some of you may have recently started using Kotlin Flow, the new framework by JetBrains to handle observable streams.Īs you probably already know from many articles on the internet, in order to collect a flow, you have two main options. ![]() Differences in methods of collecting Kotlin Flows
0 Comments
Leave a Reply. |