question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: Bluebird streams

See original GitHub issue

A lot of the bluebird feature requests deal with lists and iterables and various methods to execute them. Proposals include sequential iteration, concurrency controls (#1100), infinite list iteration (#1143) and so on.

In my opinion, adding new array/iterable methods is neither elegant (utility grab bag) nor efficient (entire arrays are allocated and held in memory even when there is no reason to do that).

Bluebrid would benefit from a compatible object stream library that works well with it. A good place to start would be the Dart stream API - its designed incredibly well. Promise-related feature highlights:

  • asyncMap - like map, but returned promises are assimilated.
  • asyncExpand - this would simply be flatMap
  • any / firstWhere / fold / join etc - we could use JS Array method names such as includes / reduce when equivalents exist
  • toList / toSet could also have equivalents (toArray, toSet)

Concurrency limits don’t exist in Dart, and the API I implemented in promise-streams is fairly clunky:

https://github.com/spion/promise-streams

Some other random benefits from the integration:

  • promise.asStream(), which would be the equivalent of Dart’s Future.asStream
  • promise.unpackStream() - converts a Promise<Stream<T>> to a Stream<T>

Motivating code example:

api.search('query')
  .then(resultPage => Stream.iterate(page => page.getNextPage(), resultPage))
  .unpackStream()
  .flatMap(page => page.getImageUrls())
  .asyncMap(url => download(img), {concurrency: 8})
  .asyncReduce((accumulatedImage, img) => stitchImage(accumulatedImage, img))

Other ideas on how this library could be designed are collected here: https://gist.github.com/spion/ecdc92bc5de5b381da30

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
spioncommented, Aug 30, 2016

@benjamingr well, try it out on the example I gave. I think the fluent API makes a big difference.

There is also promise.toStream() as well as many stream methods above that return a promise (any, first, firstWhere, last, all, toArray and many more)

(Really, can’t wait for the bind operator to come soon enough!)

0reactions
jacoscazcommented, Nov 3, 2017

Another library to check out: https://github.com/RubenVerborgh/AsyncIterator

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bluebird free live stream: How to watch online without cable
The film focuses on the Bluebird Cafe in Nashville, Tennessee, and features performances and interviews from Taylor Swift, Garth Brooks, ...
Read more >
How to watch and stream The Blue Bird - 1940 on Roku
Streaming on Roku. The Blue Bird, a fantasy movie starring Shirley Temple, Spring Byington, and Nigel Bruce is available to stream now.
Read more >
RentWorks Features - Bluebird Auto Rental Systems
RentWorks was designed with direct input from auto rental operators. Streamline your operation with the time-saving features and reports RentWorks offers.
Read more >
Creature Feature: Eastern Bluebird - Raritan Headwaters
Creature Feature: Eastern Bluebird ... Habitat: Eastern bluebirds can be found in meadows and open areas. Food: Eastern bluebirds feed on insects ...
Read more >
Bluebird - Rotten Tomatoes
... singers/songwriters -- including Garth Brooks, Vince Gill and Taylor Swift -- discuss their memories of performing at the Bluebird Cafe in Nashville,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found