Refactor VirtualTimer and expose it in scheduler package
Hello since this is my first commit please review carefully and let me know for any mess ups. As the title says I exposed VirtualTimer on the @most/scheduler package and updated the types (flow and typescript) and the docs.
Apart from the refactoring I did on VirtualTimer I have changed some behavior in it that I found puzzling at least for me. So please verify if the new behavior is the wanted one.
More specifically
- when we had a
setTimer()with adt> than thedtspecified in thetick()invocation the timersnow()time progressed at thedtof thesetTimer()and the set function was also called. - Also during the invocation of the
fngiven to thesetTimerthetimer.now()returnedInfinity
both above behaviors are now changed so
- calling
tick()is going to result to forwarding the time at thedtspecified in that invocation (calling thefnset withsetTimerif itsdtis passed) - Also during invocation of a
setTimerfnthetimer.now()returns the correct time
As a test I replaced the old VirtualTimer on the @most/core tests and run the tests with success, so I guess that the behavior that I have changed was not something that a test was relying on.
This looks really awesome, @nikoskalogridis. I hope to make time to review it soon!
I think it would be a good idea to add two more functions on the VirtualTimer:
start(): void
stop(): void
Thoughts?
@nikoskalogridis Can you say a bit more about what you envision as the behavior start() and stop(), and maybe show examples of how someone would use them in a test? Thanks!