Hurry! How to monitor the value change of the page?

1. Requirements: the page first renders a pile of data (old values), then returns changed data (new values) every 3 seconds, and re-renders the corresponding data on the page (the old values will be overwritten by new values).
2. Problem: if the newly returned value is greater than the old value, an upward arrow appears and disappears after 5 seconds; otherwise, the arrow is down;
3. There are thousands of values on the page. The new values that change every 3 seconds will not return too many, ranging from 20 to 1.
from thunderspeed network click to jump


WebSocket and vue are recommended. Websocket is used to push returned data from the server, with new and old values each time ({old:0.833,now:0.855}), vue can be used for data binding. There is no need to operate dom, to add corresponding class


if the updated data is requested at fixed intervals, of course, use polling . If the backend pushes data actively, of course, use websocket . As for how the page is rendered, it depends on what framework you use, react , vue is fine.

Menu