Hello,
I’ve made an Ionic angular app that reads and writes data from/to a mysql database.
In the section I’m working now there is a list of orders: i get the list with a http get request from my backend and then I show it looping the response with *ngFor. Every 60 seconds i do a new http request for updating the orders list.
Everything works just fine.
But how can I show an alert with the newest values only?
The practical example would be a printer connected to my app that prints every new order from the backend, a restaurant for example, that prints automatically the new orders
Thank you 
I would expect this to be murderous on battery life, so eventually you may wish to look into a push notification solution.
The first solution that comes to mind would be to have some sort of “recorded” field in each order, and a counter in the frontend app indicating “I’ve displayed everything recorded before 2021-01-02 03:04:05”. Each request could include their “seen everything before” timestamp in the request, and the server could then respond only with orders recorded after then.
Yeah that’s how I managed to "fix it temporarily " but I was looking for a more elegant way
thank you!
I would think an alert with changes is a side effect you could establish adding the tap operator to the rxjs pipe, and then use the timestamp to filter out/count/give any info you like to give.
Tap I think is a typical side-effect operator - you do need to use sparingly imho
thank you, i’ll try this solution too.
You could also try out something like a ‘subscription’ if the framework and / or SDK / library you are using support such API. That way only recent records could be fetched from the DB.