Spring Boot Reactive Programming Webflux map vs flatMap, log and filter Flux
Vložit
- čas přidán 27. 08. 2024
- What is the difference on the webflux Flux map and flatMap methods?
Enjoy! :-)
Thank you for commenting and asking questions.
Get 25 % discount on your Minecraft servers at Shockbyte.com by using this refferal link:
shockbyte.com/...
The code is located here:
github.com/eki...
Follow me on twitter:
/ mikemoelnielsen
Support me on Patreon:
/ mikemoellernielsen
As an Amazon Associate I earn from qualifying purchases.
Check out the stuff that I like (always updated):
kit.co/MikeMoe...
This was really informative. Thank you!
You are welcome. Thank you for watching and commenting
Thanks Mike :)
You are welcome :)
Thanks for the video. I am still wrapping my head around the reactive programming paradigm. Quick question:
Way I understand is how your code works is that ".map" is also async and as soon as it returns a single ship, it passes it straight to the ".flatMap" which does its own processing of THAT 1 ship. First .map does not wait for all the ships to be "loaded" before sending them to the next process?
Assuming this simulates a DB call (findById), would you say reactive approach is still preferred if your DB was simply returning 1 ship (Or based on this example - your Flux only had 1 ship? Or would that be an overkill?
Once again, great walkthroughs.
With reactive programming nothing waits for anything unless you want it to. The point is to receive and send data async because it can then be done more efficient. If you don't need the extra "power" then it is easier to use and debug a classic http rest endpoint. :-)
Thanks for the video. I am new to reactive programming. Quick Question: As in the example shown the flow of code reaches end of the programme before processing the code in the flatmap, what if we want the code to run the code in flatmap first then reach the end of code and return a particular value which was processed in flatmap?
You can force the promise to wait. Check out javascript doc. search for await
map is transform with sync
flatmap is transform with async
right?
I don't remember :)