We create a report about the current opened products.
We use Angular Component that is responsible to show a product by its id.
So if a product page is opened, the frontend instantly sends a notification with tenantId
and productId
so we increase this productId in this tenantId by one and vice versa when the user closes the product component, the frontend sends a notification with tenantId and productId so we decrease this productId in this tenantId.
Scenario:-
User1 open product page so front send {"tenantId":"abc","productId":1}
so in backend in temporary map increase this productId in this tenantId
User2 open product page so front send {"tenantId":"abc","productId":1}
so in backend in temporary map increase this productId in this tenantId
User2 closed product page so front send {"tenantId":"abc","productId":1}
so in backend in temporary map decrease this productId in this tenantId
But the problem is when the frontend sends a notification when the user closes the browser or closes the browser tap the request is already triggered but not complete.
So what is the best practice to complete this task?
No necessary this implementation you can give any workaround.