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.

你可能感兴趣的:(Mono Map vs Flatmap)