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

Add withSuspenseConfig API #15593

Merged
merged 14 commits into from
May 16, 2019
Merged

Commits on May 16, 2019

  1. Add suspendIfNeeded API and a global scope to track it

    Adds a "current" suspense config that gets applied to all updates scheduled
    during the current scope.
    
    I suspect we might want to add other types of configurations to the "batch"
    so I called it the "batch config".
    
    This works across renderers/roots but they won't actually necessarily go
    into the same batch.
    sebmarkbage committed May 16, 2019
    Configuration menu
    Copy the full SHA
    dae328f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    53f94f9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    58671af View commit details
    Browse the repository at this point in the history
  4. Track if there was a processed suspenseConfig this render pass

    We'll use this info to suspend a commit for longer when necessary.
    sebmarkbage committed May 16, 2019
    Configuration menu
    Copy the full SHA
    aee7a4a View commit details
    Browse the repository at this point in the history
  5. Mark suspended states that should be avoided as a separate flag

    This lets us track which renders we want to suspend for a short time vs
    a longer time if possible.
    sebmarkbage committed May 16, 2019
    Configuration menu
    Copy the full SHA
    f80e403 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b9e467a View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    df782f6 View commit details
    Browse the repository at this point in the history
  8. Suspend the commit even if it is complete if there is a minimum delay

    This can be used to implement spinners that don't flicker if the data
    and rendering is really fast.
    sebmarkbage committed May 16, 2019
    Configuration menu
    Copy the full SHA
    8660f24 View commit details
    Browse the repository at this point in the history
  9. Default timeoutMs to low pri expiration if not provided

    This is a required argument in the type signature but people may not
    supply it and this is a user facing object.
    sebmarkbage committed May 16, 2019
    Configuration menu
    Copy the full SHA
    044af3c View commit details
    Browse the repository at this point in the history
  10. Rename to withSuspenseConfig and drop the default config

    This allow opting out of suspending in some nested scope.
    
    A lot of time when you use this function you'll use it with high level
    helpers. Those helpers often want to accept some additional configuration
    for suspense and if it should suspend at all. The easiest way is to just
    have the api accept null or a suspense config and pass it through. However,
    then you have to remember that calling suspendIfNeeded has a default.
    
    It gets simpler by just saying tat you can pass the config. You can have
    your own default in user space.
    sebmarkbage committed May 16, 2019
    Configuration menu
    Copy the full SHA
    0c902e4 View commit details
    Browse the repository at this point in the history
  11. Track the largest suspense config expiration separately

    This ensures that if we've scheduled lower pri work that doesn't have a
    suspenseConfig, we don't consider its expiration as the timeout.
    sebmarkbage committed May 16, 2019
    Configuration menu
    Copy the full SHA
    367354d View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    1f889b6 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    d937e45 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    4347de6 View commit details
    Browse the repository at this point in the history