-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
collect methods for ReceiveChannel. #69
collect methods for ReceiveChannel. #69
Conversation
Hi, For uniformity with
Finally
http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/index.html |
I've actually given some thoughts to the issue of naming these methods. I considered
As for the
|
If lazy |
@cypressious The reason I introduced |
Support for channel-transformation function was already in my to-do list for quite a while and I'm glad it is not just a theoretical curiosity of mine, but indeed a practical issue. The naming of these functions is a tough call. Naming various The reason for thought is not just their names and semantics, but their piece in the larger scheme of things. Currently, Kotlin has Now, Actually, we might, one day, introduce concepts (or type classes) and a first-class Kotlin entity, thus shifting the task of generating the code for all those |
Not quite,
|
0b13569
to
35d2c34
Compare
I'm sorry I'm dragging feet on this PR. It is also related to #88 and is a part of a large piece of work to provide the same set of operations for |
Method to save channel to various collections are now a part of |
Let's say I have a component, which reads a list of users from a database. A natural API could look like this:
This way I can do sth with every user as they come. However, in some cases I'd like to get all users as a collection (e.g. a list). It would be convenient to have extension functions, which can receive all elements from a
ReceiveChannel
and create a list/set/map/sequence.In the attached code you can find four of these. They are based on similar methods of Flux from Project Reactor. I created only basic variants of these methods, but if needed, I can create more involved ones (e.g. this version of
collectMap
).The four extension functions signatures are: