Csaba Skrabák - 2024-03-26

E.g. the clock as an Observable:

observable = secondly25times.polled(() => new Date().toString())
observable.onSet(callback)

The callback will be called secondly once, because the toString() keeps returning the same until the second hand of the clock ticks. It updates no later than 40 milliseconds after the second really begins.

To make it less CPU-consuming, you can give up on accuracy (can update a whole second later than the beginning of that second, but contains microsecond info.)
observable = secondly.polled(() => new Date())

 

Last edit: Csaba Skrabák 2024-04-03