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

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • 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.

КОМЕНТАРІ • 11

  • @mostinho7
    @mostinho7 Рік тому +2

    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

  • @MrSATYAMJOSHI
    @MrSATYAMJOSHI Рік тому +1

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

  • @dadylle
    @dadylle 2 роки тому

    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.

  • @arnav_gaur
    @arnav_gaur 2 роки тому

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

  • @alanmangroo3656
    @alanmangroo3656 2 роки тому

    Great video. Thanks!

  • @mrrishiraj88
    @mrrishiraj88 2 роки тому

    Good day greetings

  • @manamohansamal1040
    @manamohansamal1040 2 роки тому

    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 2 роки тому +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 2 роки тому

      @@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 2 роки тому +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.

  • @shivask5543
    @shivask5543 Рік тому

    👌!! Thanks!!