The document discusses building a full-stack reactive application with Spring WebFlux for the backend and Angular for the frontend. It covers reactive programming concepts, implementing a reactive backend with Spring WebFlux, building a reactive frontend with Angular, and managing state with NgRx and RxJS. Code samples are provided for a reactive Mongo repository, controller, and integrating Angular Http calls with Spring endpoints.
24. Controller: WebFlux x MVC
@GetMapping
public Flux<Product> getAll() {
return repository.findAll();
}
@GetMapping
public List findAll(){
return repository.findAll();
}
WebFlux
MVC
@loiane
25. Controller: WebFlux x MVC
@GetMapping(â{id}")
public Mono<ResponseEntity<Product!>> getById(@PathVariable String id) {
return repository.findById(id)
.map(product !-> ResponseEntity.ok(product))
.defaultIfEmpty(ResponseEntity.notFound().build());
}
@GetMapping(path = {"{id}"})
public ResponseEntity<Contact> findById(@PathVariable("id") long id){
return repository.findById(id)
.map(record !-> ResponseEntity.ok().body(record))
.orElse(ResponseEntity.notFound().build());
}
WebFlux
MVC
@loiane
26. Mundo Real
List<Order> getOrders(int customerId)
List<Product> getProducts(Order order)
ShippingStatus getShippingStatus(Order o, Product p)
getOrdersAsync(1) !// Flux<Order>
    .flatMap(o !-> getProductsAsync(o) !// Flux<Product>
            .flatMap(p !-> getShippingStatusAsync(o, p))
    );
@loiane
37. Fluxo de Dados AssĂncrono
Reducer
dispatch
Store
subscribe
Requisita
Ação
Action
Executa o Reducer
Estado
Atualiza a View
Retorna um novo Estado
Component
@loiane