core icon indicating copy to clipboard operation
core copied to clipboard

Refactor VirtualTimer and expose it in scheduler package

Open nikoskalogridis opened this issue 7 years ago • 3 comments

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 a dt > than the dt specified in the tick() invocation the timers now() time progressed at the dt of the setTimer() and the set function was also called.
  • Also during the invocation of the fn given to the setTimer the timer.now() returned Infinity

both above behaviors are now changed so

  • calling tick() is going to result to forwarding the time at the dt specified in that invocation (calling the fn set with setTimer if its dt is passed)
  • Also during invocation of a setTimer fn the timer.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.

nikoskalogridis avatar Apr 12 '18 20:04 nikoskalogridis

This looks really awesome, @nikoskalogridis. I hope to make time to review it soon!

briancavalier avatar Apr 12 '18 21:04 briancavalier

I think it would be a good idea to add two more functions on the VirtualTimer:

start(): void
stop(): void

Thoughts?

nikoskalogridis avatar Apr 16 '18 06:04 nikoskalogridis

@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!

briancavalier avatar Apr 20 '18 00:04 briancavalier