Mono Map vs Flatmap

https://stackoverflow.com/questions/56496426/project-reactor-mono-map-vs-mono-flatmap

Mono#flatMap takes a Function that transforms a value into another Mono. That Mono could represent some asynchronous processing, like an HTTP request.

On the other hand, Mono#map takes a Function that transforms a value of type T into another value, of type R. That transformation is thus done imperatively and synchronously (eg. transforming a String into an URL instance).

The other subtlety with flatMap is that the operator subscribes to the generated Mono, unlike what would happen if you passed the same Function to map.

发布了83 篇原创文章 · 获赞 0 · 访问量 844

猜你喜欢

转载自blog.csdn.net/michaelforgood/article/details/103618709
今日推荐