baxter
05/07/2021, 4:07 AMcollect { }
. His issue was that the AS was expecting him to add the @InternalCoroutinesApi
annotation, and it also required he add in the FlowCollector
object implementation directly. At first I didn't know what happened, until he showed me the source code of the collect
function he was calling. Turned out it was the collect
function from the Flow.kt
file. I asked if he had the option to do the auto-import for the extension function collect
, but he didn't. I tried just typing out the collect
function out without auto-complete, and saw this happening on my machine as well. This confused my teammate who is learning Coroutines and Flows, but I'm curious if anyone else has run into this either personally or with teammates.baxter
05/07/2021, 4:14 AMephemient
05/07/2021, 4:51 AMThis method should never be implemented or used directly.
ephemient
05/07/2021, 4:52 AMcollect
, not the method collect
. https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/collect.htmlephemient
05/07/2021, 4:55 AMbaxter
05/07/2021, 5:28 AMcollect
, however my teammate is new to Flows, and was confused at first about why collect
was giving him problems. He didn't use auto-complete, he just typed out the call to collect
, which led to him calling the method instead of the extension function. The frustrating part was that he didn't know he had to import the extension function, as he never got the indication to do so after typing out the call to collect
.baxter
05/07/2021, 5:29 AMJoost Klitsie
05/07/2021, 6:26 AMJoost Klitsie
05/07/2021, 6:26 AMephemient
05/07/2021, 6:44 AMcollect
names are part of the public API and can't be changed (well, @InternalCoroutinesApi
doesn't have stability guarantees, but it would still be a breaking change to rename it), so we'll have to live with this situation for the time being. can ask in #coroutines but I think JB has some ideas about getting rid of the collect
method altogether, eventually.baxter
05/07/2021, 8:47 AM