liveBook · Manning

Range

As explained in Spring in Action, Sixth Edition

range is a Project Reactor factory operation that creates a Flux emitting a finite sequence of consecutive integers.

range() creates a Flux that emits a finite, consecutive sequence of integers. Give it a starting value and a count; Flux.range(1, 5) publishes 1 through 5 and then completes. section 11.3.1

@Test
public void createAFlux_range() {
  Flux<Integer> intervalFlux = 
      Flux.range(1, 5);
  
  StepVerifier.create(intervalFlux)
      .expectNext(1)
      .expectNext(2)
      .expectNext(3)
      .expectNext(4)
      .expectNext(5)
      .verifyComplete();
}

This test creates a range Flux, verifies each emitted integer with StepVerifier, and confirms completion. section 11.3.1

Use range() when a reactive pipeline needs counter-like data without an existing collection. Unlike interval(), it emits a bounded sequence immediately from explicit range parameters rather than repeatedly on a time duration. section 11.3.1

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains parameters, emitted values, completion, and test verification, but does not discuss implementation internals.
Examples
Uses Flux.range(1, 5) and verifies the integers 1 through 5 before completion.
What it assumes
Assumes familiarity with Flux and introduces verification through StepVerifier in the example.
What you can do after
Apply it via Project Reactor to create and verify a finite integer-emitting Flux.
How it connects
Connects range() with Flux, StepVerifier, and interval().

Also explained in

Compare how 8 books explain range →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.