-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Currently, when the queue is flushed, any pending async updates are cancelled.
To ensure that to props are never lost, the controller merges them into its merged object, which is iterated in the diff method.
Merging has the consequence of immediately starting the pending async updates, which I believe is rarely what the user wants. For example, let's say useTransition is running enter animations on its items along with the trail prop (creating a staggered effect). When useTransition is then passed an update, the trail prop is effectively ignored and all enter animations begin at the same time.
I think we can do better.
One idea is to attach a timestamp to every flush. Then we never need to cancel anything on flush. Instead, when a pending async update is ready to diff, it checks the timestamp of each animation it wants to update. If the animation has a greater timestamp, skip updating it. By never cancelling on flush, we ensure that end values are never lost. By attaching a timestamp, we ensure that newer updates take precedence over async updates.
Feedback wanted. Thanks!