In search for a timer - triggered every minute, on the minute - that doesn't drift, I found this solution. However I'm having difficulties understanding how to use / construct the last parameter scheduler?: SchedulerLike
.
const noDrift = generate(
0,
_ => true, // start condition
i => ++i, // iterate
i => i, // result selector
i => ... // scheduler?: SchedulerLike; every minute on the minute, but how?
);
noDrift.subscribe(() => {
// action
});
original solution that drifts:
const date = new Date();
// calculate how many ms are left till the full minute is reached
const tillNextFullMinute = (60 - date.getSeconds()) * 1000 - date.getMilliseconds();
// start on the next full minute, then just every minute
this.currentTime = timer(tillNextFullMinute, 60 * 1000);
this.currentTime.subscribe(value => {
// action
});