In the context of using Angular with .net Core WebApi, let's consider the development of a time management application designed to monitor task durations. The user initiates a task on the front end which triggers a timer displaying elapsed time.
The concept involves retrieving the elapsed time data from the backend. When a user begins a task on the front end, a timer starts on the backend and sends the current elapsed time back to the front end for display. The goal is to ensure accurate time tracking even in cases of connection issues between the backend and frontend.
To illustrate this scenario: the backend stream sends out values every second (representing the elapsed time displayed to the user). However, if there is a temporary connection disruption after 6 seconds, causing a delay before sending "9" ("0:09"), it might confuse the user ("it was at 6 seconds and now suddenly 9?"). To address this, an interval is set up on the front end to emit a new value each second. This allows for checking whether the backend stream has sent a new value within that timeframe, and if not, the previous value can be adjusted to ensure the user sees the correct elapsed time.
bStream => ---1---2---3---4---5---6---x---x---9
fStream => ---1---2---3---4---5---6---7---8---9
What the user observes:
00:01 -> 00:02 -> 00:03 -> 00:04 -> 00:05 -> 00:06 (pause) -> 00:09
Desired user experience:
00:01 -> 00:02 -> 00:03 -> 00:04 -> 00:05 -> 00:06 -> (pause - frontend detects no new value and adds 1 second to the previous)
Resulting sequence:
00:01 -> 00:02 -> 00:03 -> 00:04 -> 00:05 -> 00:06 -> 00:07 -> 00:08 -> 00:09
Facing some challenges in determining where to begin this process.
Created a quick fiddle with two streams but struggling to figure out how to detect when bStream does not emit a new value.