liveBook · Manning

Just

As explained in Spring in Action, Sixth Edition

just is a Project Reactor factory operation that creates a publisher whose signals are driven by specified existing objects.

just() is a Project Reactor factory operation for creating a Flux or Mono from specified existing objects. Flux.just() can publish several values, while Mono.just() represents one value in a reactive pipeline. section 11.3.1 section 11.2

Creating and consuming a Flux

Flux<String> fruitFlux = Flux.just("Apple", "Orange", "Grape", "Banana", "Strawberry"); fruitFlux.subscribe(f -> System.out.println("Here's some fruit: " + f)); Creating the Flux does not start data flow. Calling subscribe() activates the publisher and sends its values to the subscriber. section 11.3.1

Use just() when:

  • You already have one or more objects that should drive a reactive publisher. section 11.3.1
  • You want to place a known value at the beginning of a pipeline and transform it with operations such as map(). section 11.2
  • You want to verify emitted values and completion with StepVerifier rather than only printing them. section 11.3.1
@Test
public void createAFlux_just() {
  Flux<String> fruitFlux = Flux
      .just("Apple", "Orange", "Grape", "Banana", "Strawberry");
}

This listing shows a complete Flux.just() test setup with five specified fruit values. section 11.3.1

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains factory creation, subscription-driven flow, pipeline placement, and StepVerifier testing without descending into implementation internals.
Examples
Uses fruit values in Flux.just(), a greeting pipeline with Mono.just(), subscription output, and StepVerifier assertions.
What it assumes
Assumes basic Java lambdas and introduces Flux, Mono, publishers, subscribers, and reactive pipelines through examples.
What you can do after
Builds a Flux or Mono from known values, subscribes to it, transforms its data, and verifies emissions with StepVerifier.
How it connects
Connects just() with Flux, Mono, map(), subscribe(), Publisher, Reactive Streams, and StepVerifier.

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.