What I'm saying is that conceptually having a single item or a stream are 
two different things and this should be reflected in the type system (e.g. 
rx Task).  What you're suggesting is implementation details, the assumption 
that a source will only emit 1 item is nowhere to be seen in the type.
if I have a signature that returns (or takes) a Stream[T] I don't see the 
constraint that that stream will never have more than 1 item.

A Future is a very different animal from the Stream, especially because it 
represents a computation that's already happening. I have no way (afaik) of 
expressing in a type signature that "this is a blueprint for a source of a 
single (or zero) item". 

Look at the rx Observable.single method. It does that but it doesn't 
express it in the type system (as Task does). A lot of use cases involve 
Observables/Producers/Sources that can possibly have only one item, hence 
this PR: https://github.com/ReactiveX/RxJava/pull/2641.


On Monday, 16 February 2015 18:41:07 UTC, Jim Hazen wrote:
>
> These days the current API supports a number of ways of constructing a 
> Source.
>
>
> http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M3/?_ga=1.72893075.1209102577.1407799351#akka.stream.scaladsl.Source$
>
> Based upon these available methods, if I needed to supply 0 or 1 elements 
> based upon some business logic, I would probably create a custom iterator 
> implementation.  Your business logic can then determine whether to emit an 
> element or provide hasNext=false, which I believe will signal that the 
> source is empty and trigger a teardown of the materialized flow.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to