pekko/akka-docs/src/main/paradox/stream/operators/Source/repeat.md

1 KiB

Source.repeat

Stream a single object repeatedly.

@refSource operators

Signature

@apidocSource.repeat { scala="#repeatT:akka.stream.scaladsl.Source[T,akka.NotUsed]" java="#repeat(T)" }

Description

This source emits a single element repeatedly. It never completes, if you want the stream to be finite you will need to limit it by combining with another operator

See also:

  • @ref:single Stream a single object once.
  • @ref:tick A periodical repetition of an arbitrary object.
  • @ref:cycle Stream iterator in cycled manner.

Example

This example prints the first 4 elements emitted by Source.repeat.

Scala
@@snip snip { #repeat }
Java
@@snip snip { #repeat }

Reactive Streams semantics

@@@div { .callout }

emits the same value repeatedly when there is demand

completes never

@@@