Skip to content
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

[Mock Scheduler] Mimic browser's advanceTime #17967

Merged
merged 1 commit into from
Feb 4, 2020

Commits on Feb 3, 2020

  1. [Mock Scheduler] Mimic browser's advanceTime

    The mock Scheduler that we use in our tests has its own fake timer
    implementation. The `unstable_advanceTime` method advances the timeline.
    
    Currently, a call to `unstable_advanceTime` will also flush any pending
    expired work. But that's not how it works in the browser: when a timer
    fires, the corresponding task is added to the Scheduler queue. However,
    we will still wait until the next message event before flushing it.
    
    This commit changes `unstable_advanceTime` to more closely resemble the
    browser behavior, by removing the automatic flushing of expired work.
    
    ```js
    // Before this commit
    Scheduler.unstable_advanceTime(ms);
    
    // Equivalent behavior after this commit
    Scheduler.unstable_advanceTime(ms);
    Scheduler.unstable_flushExpired();
    ```
    
    The general principle is to prefer separate APIs for scheduling tasks
    and flushing them.
    
    This change does not affect any public APIs. `unstable_advanceTime` is
    only used by our own test suite. It is not used by `act`.
    
    However, we may need to update tests in www, like Relay's.
    acdlite committed Feb 3, 2020
    Configuration menu
    Copy the full SHA
    fe17821 View commit details
    Browse the repository at this point in the history