当用户导航到另一个页面时,如何处理Angular Frontend中延迟的HTTP响应?
我有一个Angular应用程序,一旦将一个人签到房间,他们就会添加到列表中,并将其数据发送到第三方系统。现在,将数据发送给第三方系统每3分钟就会通过后端进行一次批处理。只有成功传输数据时,才能完全注册,并在列表上的名字旁边有一个绿色复选标记。否则,尽管该人被签入,但他仍然被标记为黄色。
因此,每次签入一个人时,都会通知后端并持续数据。然后,通过每三分钟进行批处理处理,转移会发生到另一个系统。
如何通知Angular应用程序成功,以便所有转移的人都在列表上的名称旁边有绿色复选标记
?仅在批处理作业完成并且转移成功后,后端才会做出回应。因此,这将是每个请求延迟的HTTP响应3分钟。 我想肯定有一种更好的方法可以做到这一点!
I have an Angular application, where once a person is checked in to the room, they are added to a list and their data is sent to a third party system. Now the sending of the data to the third party system happens every 3 minutes in batches via the backend. Only when the data is transferred successfully is the person completely registered and has a green check mark next to his name on the list. Otherwise though the person is checked in, he is still marked as yellow.
So, each time a person is checked in, the backend is notified and the data is persisted. Then the transfer happens to another system through a batch processing every three minutes.
How to notify angular app that the transfer was successful, so that all persons transferred have the green check mark next to their name on the list?
I was thinking that each time a person gets added the request is sent to backend and the backend will respond only after the batch job completes and the transfer is successful. So that would be a delayed http response of 3 minutes per request.
I guess there is definitely a better way to do this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以采用两种主要方法,将数据从后端发送到前端:
设置套接字连接并在希望通知客户端时从服务器发出事件(<) em>阅读 this )
do 投票在服务器上(根据您的整体体系结构,客户次数等,服务器流量可能有些沉重)(读取 this )
投票通常更容易执行,但不是实时的,您必须考虑服务器上的潜在负载。插座是实时的,但是您必须调整架构才能适合它们。
There are two main ways you can go about sending data from your backend to your frontend:
Set up a socket connection and emit an event from the server when you want the client to be notified (read this)
Do polling on server (can be a little heavy on the server traffic depending of your overall architecture, number of clients, etc) (read this)
Polling is generally easier to do, but is not real time and you have to consider the potential load on your server. Sockets are real time, but you have to adjust your architecture to fit them in.