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 convenience constructor: Stream.single(T value) #29467

Open
tvolkert opened this issue Apr 25, 2017 · 3 comments
Open

Add convenience constructor: Stream.single(T value) #29467

tvolkert opened this issue Apr 25, 2017 · 3 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-l library-async type-enhancement A request for a change that isn't a bug

Comments

@tvolkert
Copy link
Contributor

I often find myself returning streams with a single value. A convenience constructor would alleviate the following:

new Stream<T>.fromIterable(<T>[value])

@lrhn
Copy link
Member

lrhn commented Apr 25, 2017

There is new Future<T>.value(value).asStream().

@tvolkert
Copy link
Contributor Author

I lump that in with new Stream<T>.fromIterable(<T>[value]) -- both work well enough, but they obscure the code ever so slightly.

I'm of two minds on convenience methods/constructors. On one hand, they bloat the API, but on the other, they make calling code look cleaner...

@anders-sandholm anders-sandholm added 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 labels Apr 25, 2017
@lrhn
Copy link
Member

lrhn commented Aug 17, 2017

It is indeed a balancing problem. The utility constructor (or function or class) should be used often enough that it outweighs the extra complexity, be it space, namespace, or user consideration of whether to use it (which requires understanding it), that the feature adds just by existing.

I'm not sure a Stream.single carries its own weight in the platoform libraries, but it could if put in package:async (by being optional, not everybody is affected by the extra complexity, something the platform libraries cannot claim).

@floitschG floitschG added core-n and removed core-m labels Aug 21, 2017
@floitschG floitschG added core-l and removed core-n labels Sep 7, 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-l library-async type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants