add Source.never (#29008)

* add Source.never

* make Source.never single instance, add DefaultAttributes
This commit is contained in:
contrun 2020-05-06 16:33:15 +08:00 committed by GitHub
parent b2509efdb0
commit 2104849658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 80 additions and 0 deletions

View file

@ -4,6 +4,8 @@ Complete right away without ever emitting any elements.
@ref[Source operators](../index.md#source-operators)
@ref:[`Source.never`](never.md) a source which emits nothing and never completes.
## Signature
@apidoc[Source.empty](Source$) { scala="#empty[T]:akka.stream.scaladsl.Source[T,akka.NotUsed]" java="#empty()" java="#empty(java.lang.Class)" }

View file

@ -0,0 +1,27 @@
# never
Never emit any elements, never complete and never fail.
@ref[Source operators](../index.md#source-operators)
@ref:[`Source.empty`](empty.md), a source which emits nothing and completes immediately.
## Signature
@@signature [Source.scala](/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala) { #never }
@@@
## Description
Create a source which never emits any elements, never completes and never failes. Useful for tests.
## Reactive Streams semantics
@@@div { .callout }
**emits** never
**completes** never
@@@

View file

@ -36,6 +36,7 @@ These built-in sources are available from @scala[`akka.stream.scaladsl.Source`]
|Source|<a name="lazysingle"></a>@ref[lazySingle](Source/lazySingle.md)|Defers creation of a single element source until there is demand.|
|Source|<a name="lazysource"></a>@ref[lazySource](Source/lazySource.md)|Defers creation and materialization of a `Source` until there is demand.|
|Source|<a name="maybe"></a>@ref[maybe](Source/maybe.md)|Create a source that emits once the materialized @scala[`Promise`] @java[`CompletableFuture`] is completed with a value.|
|Source|<a name="never"></a>@ref[never](Source/never.md)|Never emit any elements, never complete and never fail.|
|Source|<a name="queue"></a>@ref[queue](Source/queue.md)|Materialize a `SourceQueue` onto which elements can be pushed for emitting from the source. |
|Source|<a name="range"></a>@ref[range](Source/range.md)|Emit each integer in a range, with an option to take bigger steps than 1.|
|Source|<a name="repeat"></a>@ref[repeat](Source/repeat.md)|Stream a single object repeatedly.|
@ -484,6 +485,7 @@ For more background see the @ref[Error Handling in Streams](../stream-error.md)
* [mergePrioritized](Source-or-Flow/mergePrioritized.md)
* [mergeSorted](Source-or-Flow/mergeSorted.md)
* [monitor](Source-or-Flow/monitor.md)
* [never](Source/never.md)
* [onComplete](Sink/onComplete.md)
* [onFailuresWithBackoff](RestartSource/onFailuresWithBackoff.md)
* [onFailuresWithBackoff](RestartFlow/onFailuresWithBackoff.md)