spierce7
10/03/2019, 3:27 AMGlobalScope.launch {
flow.collect {
}
}
I’ve found other examples where a lambda works as a flow collector.Pablichjenkov
10/03/2019, 3:34 AMspierce7
10/03/2019, 5:31 AMlouiscad
10/03/2019, 6:52 AMDico
10/03/2019, 10:02 AMstreetsofboston
10/03/2019, 10:54 AMcollect
, an instance method and an extension function. For your collecting code, you'll mostly use the extension function variation.
That part was not well designed. And the (auto) import facility of the IDE doesn't help either....elizarov
10/03/2019, 12:31 PMlouiscad
10/03/2019, 12:39 PMimport kotlinx.coroutines.*
, import kotlinx.coroutines.flow.*
)streetsofboston
10/03/2019, 12:44 PMlouiscad
10/03/2019, 12:51 PMDico
10/03/2019, 5:24 PMelizarov
10/04/2019, 10:02 AMFlow
) and 100s of extensions, each of which needs a separate import.import reactor.Flowable
actually corresponds to import flow.*
in KotlinDico
10/04/2019, 10:21 AMelizarov
10/04/2019, 11:14 AMDico
10/06/2019, 9:25 AMkotlinx.coroutines.flow.Flow
,
You would get all extension functions of Flow (vast majority of operators). This makes sense because the extension functions are used as members of Flow
syntactically.
Then you just need to import flow {}
or channelFlow {}
if you use one of those, which makes sense because they are not used as members.louiscad
10/06/2019, 3:59 PMDico
10/06/2019, 4:04 PMelizarov
10/06/2019, 7:40 PMspierce7
10/06/2019, 9:35 PMlouiscad
10/07/2019, 6:53 AMelizarov
10/08/2019, 1:28 AMstreetsofboston
10/08/2019, 1:58 AMelizarov
10/08/2019, 2:20 PMspierce7
10/08/2019, 2:50 PMjw
10/08/2019, 2:53 PMspierce7
10/08/2019, 5:22 PMelizarov
10/08/2019, 5:25 PMfilter
and any other trivial operation.jw
10/08/2019, 5:29 PMelizarov
10/08/2019, 5:34 PMjw
10/08/2019, 5:37 PMelizarov
10/08/2019, 5:54 PMDico
10/09/2019, 3:52 AMjw
10/09/2019, 12:03 PMFlow
from my own repository type and want to collect it in a new file with no imports for the package. Assuming that a star import will be present already for the flow package means this consumption case is broken. Of course, it's not actually broken since the IDE handles it fine and emits the correct collect
import if you let it.spierce7
10/14/2019, 5:48 PMcollect
import. Perhaps that’s where this can be addressed. What I was hearing from @elizarov was that the only way it will work naturally is with wildcard imports.