Question: Spring boot 2 WebFlux generate Json stream in the new version

for example 

```
@GetMapping(value = "stream", produces = APPLICATION_STREAM_JSON_VALUE)
public Flux<Data> stream() {
    return Flux.interval(Duration.ofSeconds(1)).map(Data::new);
}

```

will produce issuing new data every one second

```
{"value":"1"}
{"value":"2"}
{"value":"3"}
{"value":"4"}
{"value":"5"}
{"value":"6"}

```

i have tried angular 5 httpclient 

```
findAll(): Observable<Data> {
   return this._http.get<Data>(this.url);
}

```

but it not work for me as i want to be reactive it not send me the result as it cache the result until the connection colsed

I want to ask what is the best way to handle this Json in angular 5

Answer: 
With Server-Sent Events, it can be done like that:

```
import * as EventSource from 'eventsource';
...

const eventSource = new EventSource("http://www.example.com/stream");

eventSource.onmessage = (event) => {
  const data = JSON.parse(event['data']);
}

```
That is [NDJson](https://ndjson.org) format. I managed handling it by doing this:

```
let handled = 0
http.get<any>("http://localhost:9000/myapi", {
    observe: "events",
    reportProgress: true,
    responseType: "text" as "json",
}).pipe(
    filter((e: any) => e.type === HttpEventType.DownloadProgress && e.partialText),
    map(e => e.partialText.trim().split("\n"))
).subscribe((arr) => {
    for (let i = handled; i < arr.length; i++) {
        try {
            console.log(JSON.parse(arr[i])) // Do obs.next(obj) here
            handled = i + 1
        } catch (e) { }
    }
})

```

You can wrap that code in an Observable and make `obs.next(JSON.parse(arr[i]))` where the `console.log` is at.