Close

Reactor - Creating Flux Instance Which Emits Range Of Integer

[Last Updated: Sep 27, 2020]

Flux#range() method can be used to emit a sequence of incrementing integers:

public static Flux<Integer> range(int start, int count)

Where start is the first integer to be emitted and count is the total number of incrementing values to emit, including the first value.

Example

package com.logicbig.example;

import reactor.core.publisher.Flux;

public class FluxRangeExamples {
  public static void main(String[] args) {
      System.out.println("-- Flux#range example --");
      Flux.range(1,5)
          .subscribe(System.out::println);
  }
}
-- Flux#range example --
1
2
3
4
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#Range() example Select All Download
  • reactor-create-instance-with-range
    • src
      • main
        • java
          • com
            • logicbig
              • example
                • FluxRangeExamples.java

    See Also