title: Detecting end of Flux data v.s. error
body: <p>Currently looking at SSE using Angular 5 and Spring 5 webflux. The basic application is working correctly, but whilst investigating error handling we've noticed that the <code>EventSource</code> in the angular application doesn't see any difference between spring closing the connection due to reaching the end of the Flux stream of data, and an error occuring (e.g. terminating the application mid transfer).</p>
  
  <p>The examples we've based our investigations on are the following.</p>
  
  <p><a href="https://thepracticaldeveloper.com/2017/11/04/full-reactive-stack-ii-the-angularjs-client/" rel="nofollow noreferrer">https://thepracticaldeveloper.com/2017/11/04/full-reactive-stack-ii-the-angularjs-client/</a></p>
  
  <p><a href="http://javasampleapproach.com/reactive-programming/angular-4-spring-webflux-spring-data-reactive-mongodb-example-full-reactive-angular-4-http-client-spring-boot-restapi-server#25_Service" rel="nofollow noreferrer">http://javasampleapproach.com/reactive-programming/angular-4-spring-webflux-spring-data-reactive-mongodb-example-full-reactive-angular-4-http-client-spring-boot-restapi-server#25_Service</a></p>
  
  <p>Both onerror and the completion function in the <code>EventSource</code> get called either when the data is send by spring successfully and reaches the end of the stream, which then closes the connection, or when we <kbd>ctrl</kbd>+<kbd>c</kbd> the application mid stream, or when we throw an exception randomly in the middle of sending data.</p>
  
  <p>The <code>EventSource</code> argument just contains <code>{type: 'error'}</code> in all 3 cases.</p>