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

@ -304,6 +304,13 @@ object Source {
def future[T](futureElement: Future[T]): Source[T, NotUsed] =
scaladsl.Source.future(futureElement).asJava
/**
* Never emits any elements, never completes and never fails.
* This stream could be useful in tests.
*/
def never[T]: Source[T, NotUsed] =
scaladsl.Source.never.asJava
/**
* Emits a single value when the given `CompletionStage` is successfully completed and then completes the stream.
* If the `CompletionStage` is completed with a failure the stream is failed.