Skip to content

veresdavid/reactor-basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Reactor Basics

A small collection of basic Reactor Core examples, with a bit of Star Wars flavor.

Purpose

This collection showcases the most basic operations provided by Reactor Core, which can be useful for those who are:

  • new to Reactor and want to learn the basics
  • only rarely using Reactor and want to refresh their knowledge

Background

Before creating this project, I was brand new to Reactor and started to go through different tutorials, meanwhile writing some dummy code for trying things out. Then I thought it would be nice to have a categorized collection of basic examples, that are well written and easy to understand. So later on, if don't use Reactor for a while and forget things, I can just quickly go through the examples and catch up things. But not just me, anyone who is in a similar situation can refer to it and learn the basics. So was born this repository.

Sources

Shout out to the official Reactor organisation on GitHub and to the DevDojo Academy on YouTube, the example codes have been created based on their awesome tutorials!

If you are new to Reactor, I would also like to recommend you these tutorials:

Structure

All the different examples have been written in the form of unit test cases (inspired by the DevDojo Academy tutorials). This way we can learn how to use Reactor and also learn how can we write unit tests for such code.

Each case can be separated to 3 main parts:

  • given : As in case of a regular unit test, we set up the things here that we want to test.
  • manual try : In this section, we manually try out the things we set up above with some logging.
  • when - then : The when and then sections of a unit test has been merged, as we executing the tested functionality and writing assertions to it in the same time.

Example

@Test
public void monoWithOneItem() {
    // given
    Mono<String> mono = Mono.just("Luke Skywalker")
        .log();

    // manual try
    mono.subscribe();

    TestUtil.logSeparatorLine();

    // when - then
    StepVerifier.create(mono)
        .expectNext("Luke Skywalker")
        .verifyComplete();
}

Chapters

  1. Mono
    1. Mono creation
    2. Subscribe to Mono
    3. Mono operators
  2. Flux
    1. Flux creation
    2. Flux with delayed items
    3. Flux with threads
    4. Creating a hot Flux
  3. More operators
    1. Mono with blocking IO operation
    2. Mapping options for Flux
    3. Flux with fallback
    4. Combining Fluxes
    5. Error handling while combining Fluxes
    6. Mono with defer

About

A small collection of basic Reactor Core examples, with a bit of Star Wars flavor.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages