-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
Add withSuspenseConfig API #15593
Commits on May 16, 2019
-
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.
Configuration menu - View commit details
-
Copy full SHA for dae328f - Browse repository at this point
Copy the full SHA dae328fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 53f94f9 - Browse repository at this point
Copy the full SHA 53f94f9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 58671af - Browse repository at this point
Copy the full SHA 58671afView commit details -
Track if there was a processed suspenseConfig this render pass
We'll use this info to suspend a commit for longer when necessary.
Configuration menu - View commit details
-
Copy full SHA for aee7a4a - Browse repository at this point
Copy the full SHA aee7a4aView commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for f80e403 - Browse repository at this point
Copy the full SHA f80e403View commit details -
Configuration menu - View commit details
-
Copy full SHA for b9e467a - Browse repository at this point
Copy the full SHA b9e467aView commit details -
Configuration menu - View commit details
-
Copy full SHA for df782f6 - Browse repository at this point
Copy the full SHA df782f6View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 8660f24 - Browse repository at this point
Copy the full SHA 8660f24View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 044af3c - Browse repository at this point
Copy the full SHA 044af3cView commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 0c902e4 - Browse repository at this point
Copy the full SHA 0c902e4View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 367354d - Browse repository at this point
Copy the full SHA 367354dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1f889b6 - Browse repository at this point
Copy the full SHA 1f889b6View commit details -
Configuration menu - View commit details
-
Copy full SHA for d937e45 - Browse repository at this point
Copy the full SHA d937e45View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4347de6 - Browse repository at this point
Copy the full SHA 4347de6View commit details