Skip to content

Allow callbacks to Stream methods to return Futures ala Future methods #12295

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

Closed
DartBot opened this issue Aug 7, 2013 · 3 comments
Closed
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Aug 7, 2013

This issue was originally filed by @seaneagan


Currently we have Future.forEach which allows taking some async action on items serially. This is nice, but the completion values of the Futures are discarded, and it lacks the rich API of Streams.

For example, I have this async method:

Future<bool> checkCommandExists(String command) {
  String commandChecker = Platform.isWindows ? 'where' : 'hash';
  return Process.run(commandChecker, [command])
      .then((ProcessResult result) => result.exitCode == 0);
}

Then I want to be able to do:

new Stream.fromIterable(['java', 'ant', 'maven'])
    .where((command) => checkCommandExists.then((exists) => !exists))
    .first
    .then((command) => throw 'Command $command not found');

But callbacks to Stream methods such as "where" and "map" doesn't treat returning Futures specially as many of the Future methods do. At least for Streams that have a concept of order, would need to buffer the later events until the callback completes.

@sethladd
Copy link
Contributor

sethladd commented Aug 7, 2013

Removed Type-Defect label.
Added Type-Enhancement, Area-Library, Library-Async, Triaged labels.

@DartBot
Copy link
Author

DartBot commented May 22, 2014

This comment was originally written by @seaneagan


asyncMap and asyncExpand now exist. This can be merged with issue #18331 which covers any further methods.

@kevmoo
Copy link
Member

kevmoo commented May 22, 2014

Marking as fixed. Folks can follow issue #18331 for related work


Added Fixed 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 May 22, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
This issue was closed.
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. library-async type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants