Source.applySource.from

Stream the values of an immutable.SeqIterable.

Source operators

Signature

Description

Stream the values of an immutable.SeqIterable. Make sure the Iterable is immutable or at least not modified after being used as a source. Otherwise the stream may fail with ConcurrentModificationException or other more subtle errors may occur.

Examples

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

import akka.actor.ActorRef;
import akka.stream.OverflowStrategy;
import akka.stream.CompletionStrategy;
import akka.stream.javadsl.Sink;
import akka.testkit.TestProbe;

import akka.stream.javadsl.RunnableGraph;
import java.util.concurrent.CompletableFuture;

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

Source<Integer, NotUsed> ints = Source.from(Arrays.asList(0, 1, 2, 3, 4, 5));
ints.runForeach(System.out::println, system);

String text =
    "Perfection is finally attained not when there is no longer more to add,"
        + "but when there is no longer anything to take away.";
Source<String, NotUsed> words = Source.from(Arrays.asList(text.split("\\s")));
words.runForeach(System.out::println, system);

Reactive Streams semantics

emits the next value of the seq

completes when the last element of the seq has been emitted

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.