Source.fromArray

Stream the values of an array.

Source operators

Signature

Source.fromSource.from

Description

Stream the values of a Java array.

Examples

Java
sourceimport org.apache.pekko.Done;
import org.apache.pekko.NotUsed;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.actor.testkit.typed.javadsl.ManualTime;
import org.apache.pekko.actor.testkit.typed.javadsl.TestKitJunitResource;
import org.apache.pekko.stream.javadsl.Source;

import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.stream.OverflowStrategy;
import org.apache.pekko.stream.CompletionStrategy;
import org.apache.pekko.stream.javadsl.Sink;
import org.apache.pekko.testkit.TestProbe;

import org.apache.pekko.stream.javadsl.RunnableGraph;
import java.util.concurrent.CompletableFuture;

import java.util.Arrays;
import java.util.Optional;

Source<String, NotUsed> words = Source.fromArray("Hello world".split("\\s"));
words.runForeach(System.out::println, system);

Reactive Streams semantics

emits the next value of the array

completes when the last element of the seq has been emitted