You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
}
})
The text was updated successfully, but these errors were encountered:
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
}
})
The text was updated successfully, but these errors were encountered: