thymeleaf-spring
thymeleaf-spring copied to clipboard
Support reactive data types for spring mvc
Will there be also support for using Flux or Mono in the model with servlet based Spring 5 applications?
What type of support would you be expecting for these, at the Spring MVC side?
At first thought, including a dependency on Reactor at the Spring MVC side could be an issue, but anyway I would be interested in knowing what kind of scenario would we be talking about... note the servlet web framework is blocking itself so… would you get a real advantage from using reactive data streams there?
At first thought, including a dependency on Reactor at the Spring MVC side could be an issue
I don't think so. For using the reactive WebClient inside a servlet application you have to even include Spring Webflux. Imho that's a valid use case.
What type of support would you be expecting for these, at the Spring MVC side?
most simple: I think it would be just convenient if we could pass a Flux into the model and Thymleaf can iterate on them using th:each. (Currently you need to call toIterable() on the Flux in the controller beforehand). The rendering itself would indeed be blocking.
more advanced: Afaik Spring MVC is capable of turning a Flux into SSEs using the async serlvet api. May be there is a way to easy support this with Thymeleaf. (But maybe it's much easier to map the Flux by calling Tyhmeleaf for every single item, and leave the rest of the SSE work to spring mvc)
would you get a real advantage from using reactive data streams there?
From a developers perspective it would be just for the ease of use. As you pointed out since the rendering is still blocking you would gain no further advantages.