rxjs-examples
rxjs-examples copied to clipboard
Hi I found a bug in stop watch
https://stackblitz.com/edit/rxjs-stop-watch?file=index.ts
An excellent starting point, thank you, but if you reduce the interval to say 1 millisecond, then apparently due to the execution of javascript, the stopwatch does not work correctly, greatly underestimating the time.
I came across an operator that can partially fix this problem.
switchMap((state: State) => { if (state.count) { return interval( state.speed ).pipe( timeInterval(), tap((_) => { const value = _.interval / state.speed state.value += state.countup ? value : -value }), tap(_ => this.setValue(state.value)) ) } else { return NEVER } })