+str #17203: Add extra docs to prefixAndTail

This commit is contained in:
Endre Sándor Varga 2015-07-09 14:42:28 +02:00
parent 6b4f52afb2
commit fed5e522c6
3 changed files with 24 additions and 3 deletions

View file

@ -558,10 +558,17 @@ class Flow[-In, +Out, +Mat](delegate: scaladsl.Flow[In, Out, Mat]) extends Graph
new Flow(delegate.transform(() mkStage.create())) new Flow(delegate.transform(() mkStage.create()))
/** /**
* Takes up to `n` elements from the stream and returns a pair containing a strict sequence of the taken element * Takes up to `n` elements from the stream (less than `n` only if the upstream completes before emitting `n` elements)
* and returns a pair containing a strict sequence of the taken element
* and a stream representing the remaining elements. If ''n'' is zero or negative, then this will return a pair * and a stream representing the remaining elements. If ''n'' is zero or negative, then this will return a pair
* of an empty collection and a stream containing the whole upstream unchanged. * of an empty collection and a stream containing the whole upstream unchanged.
* *
* In case of an upstream error, depending on the current state
* - the master stream signals the error if less than `n` elements has been seen, and therefore the substream
* has not yet been emitted
* - the tail substream signals the error after the prefix and tail has been emitted by the main stream
* (at that point the main stream has already completed)
*
* '''Emits when''' the configured number of prefix elements are available. Emits this prefix, and the rest * '''Emits when''' the configured number of prefix elements are available. Emits this prefix, and the rest
* as a substream * as a substream
* *

View file

@ -522,9 +522,16 @@ class Source[+Out, +Mat](delegate: scaladsl.Source[Out, Mat]) extends Graph[Sour
new Source(delegate.transform(() mkStage.create())) new Source(delegate.transform(() mkStage.create()))
/** /**
* Takes up to `n` elements from the stream and returns a pair containing a strict sequence of the taken element * Takes up to `n` elements from the stream (less than `n` only if the upstream completes before emitting `n` elements)
* and returns a pair containing a strict sequence of the taken element
* and a stream representing the remaining elements. If ''n'' is zero or negative, then this will return a pair * and a stream representing the remaining elements. If ''n'' is zero or negative, then this will return a pair
* of an empty collection and a stream containing the whole upstream unchanged. * of an empty collection and a stream containing the whole upstream unchanged.
*
* In case of an upstream error, depending on the current state
* - the master stream signals the error if less than `n` elements has been seen, and therefore the substream
* has not yet been emitted
* - the tail substream signals the error after the prefix and tail has been emitted by the main stream
* (at that point the main stream has already completed)
*/ */
def prefixAndTail(n: Int): javadsl.Source[akka.japi.Pair[java.util.List[Out @uncheckedVariance], javadsl.Source[Out @uncheckedVariance, Unit]], Mat] = def prefixAndTail(n: Int): javadsl.Source[akka.japi.Pair[java.util.List[Out @uncheckedVariance], javadsl.Source[Out @uncheckedVariance, Unit]], Mat] =
new Source(delegate.prefixAndTail(n).map { case (taken, tail) akka.japi.Pair(taken.asJava, tail.asJava) }) new Source(delegate.prefixAndTail(n).map { case (taken, tail) akka.japi.Pair(taken.asJava, tail.asJava) })

View file

@ -779,10 +779,17 @@ trait FlowOps[+Out, +Mat] {
andThenMat(MaterializingStageFactory(mkStageAndMaterialized)) andThenMat(MaterializingStageFactory(mkStageAndMaterialized))
/** /**
* Takes up to `n` elements from the stream and returns a pair containing a strict sequence of the taken element * Takes up to `n` elements from the stream (less than `n` only if the upstream completes before emitting `n` elements)
* and returns a pair containing a strict sequence of the taken element
* and a stream representing the remaining elements. If ''n'' is zero or negative, then this will return a pair * and a stream representing the remaining elements. If ''n'' is zero or negative, then this will return a pair
* of an empty collection and a stream containing the whole upstream unchanged. * of an empty collection and a stream containing the whole upstream unchanged.
* *
* In case of an upstream error, depending on the current state
* - the master stream signals the error if less than `n` elements has been seen, and therefore the substream
* has not yet been emitted
* - the tail substream signals the error after the prefix and tail has been emitted by the main stream
* (at that point the main stream has already completed)
*
* '''Emits when''' the configured number of prefix elements are available. Emits this prefix, and the rest * '''Emits when''' the configured number of prefix elements are available. Emits this prefix, and the rest
* as a substream * as a substream
* *