I'm exposing an end-point using Spring Boot and Webflux that returns an infinite stream of numbers, one every one second:
@GetMapping(value = "/infinitestreamflux", produces = MediaType.APPLICATION_STREAM_JSON_VALUE)
@CrossOrigin(origins = "http://localhost:4200")
public Flux<Long> returnInfiniteStreamFlux() {
return Flux.interval(Duration.ofSeconds(1))
.log();
}
If I call localhost:8080/infinitestreamflux from my browser, everything works fine. The results are correctly shown as they arrive.
I'd like to archieve the same result using Angular 8, but nothing is shown in the page.
This is my test component:
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
infiniteStreamFlux;
constructor(private http: HttpClient) {}
ngOnInit(): void {
this.http.get('http://localhost:8080/infinitestreamflux')
.subscribe(data => this.infiniteStreamFlux = data);
}
}
This is my very simple template:
{{infiniteStreamFlux}}
From my server log, I can clearly see that the results are being sent. and from the Chrome Dev Tools I found out that values arrive each second, even tho they're not shown in the preview tab. In the end, the page ends up being empty.
How can I solve the issue?