Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add asyncFold, asyncReduce to streams #18331

Open
DartBot opened this issue Apr 20, 2014 · 4 comments
Open

add asyncFold, asyncReduce to streams #18331

DartBot opened this issue Apr 20, 2014 · 4 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-n library-async type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Apr 20, 2014

This issue was originally filed by @tatumizer


Continuing the line started by asyncMap, asyncExpand, please add other async primitives: asyncFold, asyncReduce etc. Using asyncFold, one can implement asynchronous loops without recursion.
  

@iposva-google
Copy link
Contributor

Added Area-Library, Library-Async, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Apr 22, 2014

This comment was originally written by @seaneagan


Are there any known use cases of needing to return Futures from Stream event handlers ?

Even if so, it still seems like in most cases instead of stream.asyncFold(initial, f) you could do stream.asyncMap(f1).fold(initial, f2) for some suitable f1 and f2.

I think a more common case of "asynchronous loops" is knowing the list of values up front. Quiver has doWhileAsync, reduceAsync and forEachAsync for this:

http://google.github.io/quiver-dart/#quiver/quiver-async

@DartBot
Copy link
Author

DartBot commented Apr 22, 2014

This comment was originally written by @tatumizer


in quiver, there's a function Future * reduceAsync
<http://google.github.io/quiver-dart/#quiver/quiver-async@id_reduceAsync>\*(
Iterable <http://google.github.io/quiver-dart/#dart-core.Iterable>
iterable<http://google.github.io/quiver-dart/#quiver/quiver-async@id_reduceAsync,iterable>,
initialValue<http://google.github.io/quiver-dart/#quiver/quiver-async@id_reduceAsync,initialValue>,
AsyncCombiner<http://google.github.io/quiver-dart/#quiver/quiver-async.AsyncCombiner>
combine<http://google.github.io/quiver-dart/#quiver/quiver-async@id_reduceAsync,combine>
)
Which means you know the use case for async reduce over Iterable.
Take this iterable and send it somewhere, element by element, as a stream.
You get use case in question :-)

@lrhn
Copy link
Member

lrhn commented Apr 23, 2014

Removed Type-Defect label.
Added Type-Enhancement label.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async labels Apr 23, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@lrhn lrhn added the core-m label Aug 11, 2017
@floitschG floitschG added core-n area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. and removed area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-m labels Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-n library-async type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants