Updated RecipeController saveOrUpdate method and made it fully reacti… #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi John and staff!
I've made a change to the way RecipeController.saveOrUpdate is resolved using the guidance outlined in https://docs.spring.io/spring/docs/5.0.x/spring-framework-reference/web-reactive.html#webflux-ann-modelattrib-method-args, specifically:
"(...) Spring WebFlux, unlike Spring MVC, supports reactive types in the model, e.g. Mono or io.reactivex.Single. An @ModelAttribute argument can be declared with or without a reactive type wrapper, and it will be resolved accordingly, to the actual value if necessary. Note however that in order to use a BindingResult argument, you must declare the @ModelAttribute argument before it without a reactive type wrapper, as shown earlier. Alternatively, you can handle any errors through the reactive type:
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
public Mono processSubmit(@Valid @ModelAttribute("pet") Mono petMono) {
return petMono
.flatMap(pet -> {
// ...
})
.onErrorResume(ex -> {
// ...
});
}"
Notice that BindingResult is completely out of the picture and the method is now fully reactive.
All UT tests have been verified, along with testing recipe updates within the app.
Hope you find it useful!
Regards,
Sebastian Lopez