TIL that my coworkers are just annoyed as I am tha...
# coroutines
b
TIL that my coworkers are just annoyed as I am that the first auto-suggestion that comes for
flow.colle
is not the extension function that takes a lambda but the collect that takes a flowCollector. Not sure if there is something the library could do to improve that, or if it's more something for intellij (if I'm always selecting the 2nd suggestion, make it the first suggestion from there on?).
z
use:
Copy code
yourFlow
  .onEach { itemInFlow ->  }
  .launchIn(scope)
๐Ÿ‘ 2
๐Ÿ˜ฌ 3
but yeah, the internal
.collect(..)
API that appears in autocomplete is frustrating
o
intellij can do the latter for Java at the moment, but with a disclaimer: "Completion for chained expressions is only available for Java and requires the project to be built with the IntelliJ IDEA compiler (not the Gradle compiler)." it might be a good idea to make this an formal request for adding this to Kotlin
s
I can't find the slack thread, but I remember Roman saying that Kotlin code should use star/wildcard imports, which would then make intellisense favor the extension function
collect
. ...
b
Our team uses detekt with a rule against wildcard imports so that's a no go. I remember it was cumbersome to update intellij settings to prevent wildcards (there is no
never use wildcard imports
setting); I am curious if there is some divide between language designers and the community. I think the reasoning against wildcard imports is that they clutter the namespace. Maybe the counterargument is your file has too much scope if that's a problem.
๐Ÿ‘ 1
s
I think that Kotlin (at least some of its designers) see Kotlin using scoping through packages (and modules). Let me see if I can find Roman's post/answer about this exact same issue (and that also kicked off a star-import 'yes' or 'no' discussion).
e
The "collect" wrong-suggestion problem is going to be fixed soon. It already works much better in master branch.
๐Ÿ™Œ 5
e
How did it change on master?
e
The first auto-suggestion is now an extension function.
e
shipit
e
Will be in Kotlin 1.4.
e
Great to hear you're working on good user APIs so much. It's what many love about Kotlin, which is why it's extra annoying when one little thing is not so smooth ๐Ÿ‘