Merge pull request #20125 from kelebra/19039-kelebra-cycle
#19039: Added cycle method to Source class.
This commit is contained in:
commit
0b0a456e28
6 changed files with 61 additions and 0 deletions
|
|
@ -88,6 +88,20 @@ object Source {
|
|||
def fromIterator[O](f: function.Creator[java.util.Iterator[O]]): javadsl.Source[O, NotUsed] =
|
||||
new Source(scaladsl.Source.fromIterator(() ⇒ f.create().asScala))
|
||||
|
||||
/**
|
||||
* Helper to create 'cycled' [[Source]] from iterator provider.
|
||||
* Example usage:
|
||||
*
|
||||
* {{{
|
||||
* Source.cycle(() -> Arrays.asList(1, 2, 3).iterator());
|
||||
* }}}
|
||||
*
|
||||
* Start a new 'cycled' `Source` from the given elements. The producer stream of elements
|
||||
* will continue infinitely by repeating the sequence of elements provided by function parameter.
|
||||
*/
|
||||
def cycle[O](f: function.Creator[java.util.Iterator[O]]): javadsl.Source[O, NotUsed] =
|
||||
new Source(scaladsl.Source.cycle(() ⇒ f.create().asScala))
|
||||
|
||||
/**
|
||||
* Helper to create [[Source]] from `Iterable`.
|
||||
* Example usage:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue