0

I am searching for a solution that allows me to make an Angular component listening to a backend object which get updated by some other service.

Actually, I have a component called SignatureStatusComponent which shows the actual status of customer signature. This signatureStatus within Project object is only updated in the backend via a REST exposed endpoint to a third-party service which allows users to perform their digital signatures.

My problem is how to update in real-time the UI with the actual status once the third-party service perform the callback to change the status.

Here is a simple schema to explain more the architecture :

here

For your information, I'm using SpringBoot for backend and Angular for frontend.

Ghassen
  • 591
  • 1
  • 15
  • 33

1 Answers1

3

As I understand your question, you want to the Angular application to be notified, when something specific happens in the back-end (Spring Boot) app.

There are several possibilities, including polling, but in my opinion, the most straightforward thing would be to use Web Sockets.

On the Angular side, you can use the rxjs webSocket, which gives you an Observable that you can subscribe to for inbound messages (IIRC, you can call next() on it to send messages).

On the back-end, take a look at the TextWebSocketHandler or one of the SocketHandler classes.

The other option, if you have more complex requirements, is to use the STOMP protocol both ends - there are plenty of STOMP tutorials for Spring hanging around, and it looks like there's a STOMP implementation of the rxjs WebSocket

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
  • thank you for your suggestion .. I started implementing it but I was a bit frustrated since it was a bit complicated but after your response I was sure that's the good solution :) I'll publish a full response as soon as possible to help others maybe – Ghassen Jan 13 '20 at 22:42
  • Hello @GreyBeardedGeek, can you help me to understand, if using RxJS websocket on front end and stomp(using Spring) implementation on backend can work fine? Asking as front end architect is not fine with using stomp library as front end has rxjs lib and he dont want to increase dependencies/libs on front end(which is weird for me). And I m fine using stomp on backend as it out of box easy. trying to understand the difference here https://stackoverflow.com/questions/40988030/what-is-the-difference-between-websocket-and-stomp-protocols – lowLatency Jun 05 '21 at 03:55
  • No, you can't use the standard rxjs we socket implementation with stomp, as stomp adds an extra protocol on top. You'd have to use a stomp-specific version, such as https://github.com/stomp-js/rx-stomp – GreyBeardedGeek Jun 06 '21 at 15:32