-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(TestScheduler): add an animate "run mode" helper #5607
Conversation
f6f6988
to
6cb1c47
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIRST: I've rarely been as excited about a change to this part of the code. This is pretty much the best addition since "run mode".
Just a few very minor things.
@benlesh I'll make those changes and will then add some docs - I was holding off on documenting it until it had been reviewed. |
@benlesh I've made some changes:
ATM, the documentation in the guide is a little light, but I think it's enough, for now. Once this PR is merged, I am going to:
If the docs need more work, I can look at them after I've done the above. Or someone else can do it. |
Nice work, @cartant! I'm very pleased to see this land! |
Description:
This PR:
Adds a
Date
timestamp provider.Adds a
performance
timestamp provider.Adds a
requestAnimationFrame
provider.All providers have
delegate
properties that areundefined
by default but are used - byTestScheduler#run
- to override the default behaviour. This mirrors thedelegate
implementation detail that's used with the schedulers.Removes the arrow function from the static
Scheduler.now
- it's unnecessary, as theDate.now
call now occurs within thedateTimestampProvider
.The
animationFrames
observable now uses therequestAnimationFramesProvider
.TestScheduler#run
sets the delegates for the providers, with therequestAnimationFramesProvider
's delegate working in conjunction with aanimate()
marble that's added to the run helpers:Each time an animation/repaint occurs, all queued
rAF
callbacks will be executed - in the order in which they were scheduled - and each will be passed the same timestamp - theTestScheduler
'snow
value - which is also what will be returned from the timestamp providers - as theTestScheduler
itself is the delegate.Adds tests for the
animate
run
helper.Updates API guardian for the inclusion of the
animate
run
helper.Reimplements the
animationFrames
tests to use therun
helper and the provider - which is spied upon - and removes therAF
mock.Fixes the
rAF
provider so that cancellation of already fulfilled requests (upon unsubscription) is not attempted.Related issue (if exists): #5438 and #5475