{"id":367489,"date":"2023-06-29T13:51:53","date_gmt":"2023-06-29T12:51:53","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=idea&#038;p=367489"},"modified":"2025-09-17T14:27:59","modified_gmt":"2025-09-17T13:27:59","slug":"reactive-programming-made-easy","status":"publish","type":"idea","link":"https:\/\/blog.jetbrains.com\/fr\/idea\/2023\/06\/reactive-programming-made-easy","title":{"rendered":"Reactive Programming Made Easy\u00a0"},"content":{"rendered":"\n<p>We\u2019ve got all of the <a href=\"https:\/\/projectreactor.io\/\" target=\"_blank\" rel=\"noopener\">project Reactor<\/a> adepts and enthusiasts out there covered! Whether you&#8217;re a seasoned pro or just taking your first steps in the field, IntelliJ IDEA will make reactive coding a breeze. It simplifies the complexities of Reactive Streams, ensuring a smooth and efficient experience for all skill levels.<\/p>\n\n\n\n<p>This article covers the most significant features and tools, including live templates, a dedicated debug mode, and helpful inspections. The examples provided below are from existing projects, so we won\u2019t discuss <a href=\"https:\/\/www.jetbrains.com\/help\/idea\/reactor.html#add-reactor\" target=\"_blank\" rel=\"noopener\">adding reactor support<\/a> at the initial launch.&nbsp;<\/p>\n\n\n\n<p>Get ready to unlock the full potential of reactive programming with IntelliJ IDEA!<\/p>\n\n\n\n<p>In reactive programming, <em>Mono<\/em> and <em>Flux <\/em>are two fundamental types of the <em>Publisher<\/em> interface used to represent reactive streams. They provide powerful operators and methods to change and organize data effectively.<\/p>\n\n\n\n<p>Let\u2019s see what features and tools IntelliJ IDEA provides to conveniently work with these crucial types.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reactor live templates&nbsp;<\/h2>\n\n\n\n<p>Who doesn&#8217;t love typing less and coding faster? Reactive live templates will help you do exactly that!<\/p>\n\n\n\n<p>IntelliJ IDEA also offers a feature called postfix code completion for projects that use Reactor. With this feature, you can automatically transform a previously typed expression into a reactive one based on what you&#8217;ve written.<\/p>\n\n\n\n<p>When working on projects that have Reactor support, IntelliJ IDEA can automatically wrap an expression with the appropriate Reactor factory, either <em>Flux<\/em> or <em>Mono.<\/em><\/p>\n\n\n\n<p>Here\u2019s how you can effortlessly return Mono from the string with the help of the toMono live template:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/17bR2KD6FbS7-yI_U-kInouNiEr4oU4H8V3KhX4Q-ESf4Zdtp9BChRAU484dUS3zhXy8ql-s8aWR0X0Ps0ABAolnJwaoDj-iwzvD5SIZLj6NmWixNSdnjc-wQtOCr8qBE07Pef7kTPAwgJP2L86Pdfk.gif\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Debugging Reactor Streams<\/h2>\n\n\n\n<p>IntelliJ IDEA allows you to debug your reactive projects. Prior to starting the process, you\u2019ll need to adjust your configurations. Go to <em>Preferences\/Settings <\/em><em>|<\/em><em> Languages &amp; Frameworks <\/em><em>|<\/em><em> Reactive Streams<\/em>. Tick the <em>Enable Reactor Debug mode<\/em> option and select <em>Hooks.onOperatorDebug()<\/em>.&nbsp;<\/p>\n\n\n\n<p>Now, when the necessary configurations are there, let\u2019s see how our debugger works with reactive projects. The first thing worth noting is that it detects the <em>Flux<\/em> and <em>Mono<\/em> types while debugging. You can see them marked with green icons. Once you click on them, you\u2019ll see the results of calculations inside them on the right, in the <em>Variables<\/em> view.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/hYKCo9z4pI8CLPy-VECkIleIUrnhIPgdvQiq_nn8S_zqErrkbqnGN2YXY8r7AsEDivxiusosA5jt4xbyh97XhPAmZtAK6bHGUrT7Uz1iSUDYsxLTTvpoVICIvyPJZAV_Mu5Aow8NhiE3l8A2E6avvjU.gif\" alt=\"\"\/><\/figure>\n\n\n\n<p>It\u2019s now possible to evaluate these types. To do so, click the <em>get <\/em>or <em>collectList<\/em> link next to the displayed result. The IDE will then instantly compute the reactive stream items.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/hoNYtj2NDVCTYGPmXEUvsIm-9q2qM40l3XkP-VwLo6uU9rt3_xahG7hXQctDWDbQCOZWhQNP1A7IFTgW88ALyz-fKbzeexR8Wqkqudx8mORrsy9D9vzicHaZrtIH3u13ERa-fjkiVxsBbPN_1ItLItw.gif\" alt=\"\"\/><\/figure>\n\n\n\n<p>You can also perform more complex evaluations.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1125\" height=\"450\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/06\/image2.gif\" alt=\"\" class=\"wp-image-367698\"\/><\/figure>\n\n\n\n<p>By default, the debugger fetches the first 100 items of <em>Flux<\/em>. You can configure this number in <em>File | Settings | Languages &amp; Frameworks | Reactive Streams<\/em>. Each time you trigger a computation, the IDE subscribes to a Publisher value and assumes the operation is safe to retry.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Noteworthy inspections for daily needs&nbsp;<\/h2>\n\n\n\n<p>Our helpful inspections are always ready to highlight inconsistencies in your code \u2013 everybody can use an extra set of eyes! We\u2019ll demonstrate two of the most helpful inspections that you can benefit from when using Reactive Streams.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Unused Publisher value<\/h3>\n\n\n\n<p>To use an operator that produces a new Publisher instance, you must subscribe to the created Publisher via <em>subscribe()<\/em> or return a value from a method. If you don\u2019t do this, the created reactive stream is never used \u2013 in reactive programming terminology, \u201cThe value is never used as the Publisher type\u201d. Here is where our first inspection comes in handy by reporting unused Publisher instances.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/k2CdleOmQBnoTlCvkXnhzJXi-CAn9zyTIOtcBSCZWOxs3QkoolakHg-lGLCbYLdMvDF7dEi7J1nOrzMc_qgxEgG15CxWvhmR66VNqlQuPNuT4B9jQxumcD7Fg4G6ytrPqFJvBNfZOIjjy8HzpxTQmy0.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Blocking call in non-blocking context&nbsp;<\/h3>\n\n\n\n<p>You can use code that might cause a delay or pause in a program where it&#8217;s not supposed to. IntelliJ IDEA provides the <em>Possibly blocking call in non-blocking context <\/em>inspection that looks for situations like this.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/Ha_O4_IzVMGKiRTBHyGgv01P6hqAs74cNLWiIf506e-Gm0uuszxHP6IhQeVaFzFDP9iRrl3XzxRob3NZOZF1Qzsy8tmog5vtE2MT_nw8dUpm0-_MDuzCbiYGcdpf8BdUIL78N9bsyHZ21T-jKgQOlaE.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>It is convenient to annotate code blocks with @Blocking and @NonBlocking annotations\ufeff from the <a href=\"https:\/\/github.com\/JetBrains\/java-annotations\" target=\"_blank\" rel=\"noopener\">JetBrains annotations collection<\/a>. This helps IntelliJ IDEA detect blocking calls in non-blocking contexts. To get the annotations, add org.jetbrains:annotations version 22.0.0 or later to your project&#8217;s dependencies.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/q2eCmgoAxiV6p4oI6DJv7Yzf3Qx1lkxzWPj40Fp3-gjMJJUROSQpAIGZ9lc0rLptYdqykhY3EeYSOgFOPUzDr2zyPT7BeixudeoIkqoCN5AghQW-S_E7Yx1bUg3Osqoyj2U0uVk4CPK9q1dtRIs6Dko.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>In this article, we\u2019ve demonstrated the most helpful features IntelliJ IDEA has for developers who work with Reactive Streams. We hope that you will use them on a daily basis and enjoy smoother and faster reactive programming. If you have any ideas for other helpful features, let us know in the comments.&nbsp;<\/p>\n","protected":false},"author":1138,"featured_media":368312,"comment_status":"closed","ping_status":"closed","template":"","categories":[4759],"tags":[40,1290,492,792,3365],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/idea\/367489"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/idea"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/types\/idea"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/users\/1138"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/comments?post=367489"}],"version-history":[{"count":10,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/idea\/367489\/revisions"}],"predecessor-version":[{"id":624728,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/idea\/367489\/revisions\/624728"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/media\/368312"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/media?parent=367489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/categories?post=367489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/tags?post=367489"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/cross-post-tag?post=367489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}