Close

Reactor - Creating Flux Instance From Iterable

[Last Updated: Sep 27, 2020]

Flux#fromIterable() method can be used to create a Flux that emits the items contained in the provided Iterable.

public static <T> Flux<T> fromIterable(Iterable<? extends T> it)

Example

package com.logicbig.example;

import reactor.core.publisher.Flux;
import java.util.Arrays;
import java.util.List;

public class FluxFromIterableExamples {
  public static void main(String[] args) {
      System.out.println("-- Flux#fromIterable example --");
      List<Integer> list = Arrays.asList(1, 3, 5);
      Flux.fromIterable(list)
          .subscribe(System.out::println);
  }
}
-- Flux#fromIterable example --
1
3
5

Example Project

Dependencies and Technologies Used:

  • reactor-core 3.3.10.RELEASE: Non-Blocking Reactive Foundation for the JVM.
  • JDK 8
  • Maven 3.5.4

Reactor - Flux#fromIterable() Example Select All Download
  • reactor-create-instance-from-iterable
    • src
      • main
        • java
          • com
            • logicbig
              • example
                • FluxFromIterableExamples.java

    See Also