28 Exercise Using flatMap and distinct operators (Reactive programming with Java - full course)

Sdílet
Vložit
  • čas přidán 5. 09. 2022
  • Course: Reactive programming in Java
    Covers: Reactive fundamentals, Project Reactor
    Access this full course NOW & unlock more awesome courses like this by becoming a member:
    / @java.brains
    Website:
    www.javabrains.io
    Learn the basics of reactive programming. You will learn to "THINK REACTIVE" - understand the paradigm shift and thinking change necessary to write code in a reactive way using Project Reactor.
    New video every 3 days! Subscribe and enable notifications to be alerted.

Komentáře • 11

  • @MrSATYAMJOSHI
    @MrSATYAMJOSHI Před rokem +1

    Thank you Kaushik.
    If anyone is interested, "Spring in Action" is one of the books that explains Java Reactive programming in detail.

  • @mostinho7
    @mostinho7 Před rokem +1

    Done thanks
    Calling subscribe is what starts the flux stream, if you don’t call subscribe then it won’t get triggered even if you perform operations on the flux stream
    .distinct() operator eliminates repeated values from flux stream
    .distinctUntilChanged() will remove repeated values in a row like 1,1 but will not remove repeated values if they changed in between
    Project reactor has operators documentation to find out how each one works to transform the stream and if it is blocking or async

  • @alanmangroo3656
    @alanmangroo3656 Před rokem

    Great video. Thanks!

  • @arnav_gaur
    @arnav_gaur Před rokem

    Thanks Kaushik for the awesome content!
    I binge watched the playlist. Eagerly waiting for rest of the videos :)

  • @shivask5543
    @shivask5543 Před rokem

    👌!! Thanks!!

  • @mrrishiraj88
    @mrrishiraj88 Před rokem

    Good day greetings

  • @manamohansamal1040
    @manamohansamal1040 Před rokem

    For mapping int to its related user we are doing a filter inside a map of the first flux, so isn't that a blocking operation as the id need to wait for the user flux to complete until check for the last element complete the filter operation?

    • @adambickford8720
      @adambickford8720 Před rokem +1

      .flatMap is inherently async, it's not returning the user it's returning yet another publisher (Flux) that will eventually publish 1 user (due to the take(1)) on subscribe. FlatMap is so you don't end up with Flux which is awkward "in the future i'll give you another promise about the future" so skip the middleman and go to the last promise.

    • @manamohansamal1040
      @manamohansamal1040 Před rokem

      @@adambickford8720 yes its returning flux of flux but that doesn't guarantee to be a async process, a flux can be a sync process also.

    • @adambickford8720
      @adambickford8720 Před rokem +1

      @@manamohansamal1040 yes, you can break any contract (though a good runtime will actually prevent you from blocking).
      But the API is there to support async, which is what he's demonstrating. You also don't check for the last element, you eval each one and it short circuits after 1 hit in this case. It could literally be the first element.

  • @dadylle
    @dadylle Před rokem

    Subscribe is the contract between the source and the consumer, when data is ready the source push data to observers how are in there subscriber's list, maybe at the time of subscribing there is no data.