Docs: Reduce operator (#29641)

Co-authored-by: Arnout Engelen <github@bzzt.net>
This commit is contained in:
Muskan Gupta 2020-09-22 18:58:35 +05:30 committed by GitHub
parent 4d00f9a8e8
commit a12867b8b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 1 deletions

View file

@ -456,6 +456,15 @@ class SourceOrFlow {
// #dropWhile
}
static void reduceExample() {
// #reduceExample
Source<Integer, NotUsed> source = Source.range(1, 100).reduce((acc, element) -> acc + element);
CompletionStage<Integer> result = source.runWith(Sink.head(), system);
result.thenAccept(System.out::println);
// 5050
// #reduceExample
}
void watchExample() {
// #watch
final ActorRef ref = someActor();