Add wrapResolved to be a faster version of wrapPromise#103
Merged
Conversation
severo
approved these changes
Apr 4, 2025
Contributor
severo
left a comment
There was a problem hiding this comment.
Good idea.
An alternative would have been to keep the conditional (if (!(promise instanceof Promise)) {) in wrapPromise and just synchronously set .resolve = value and return.
But I like the clarity of one function doing one thing, so I prefer the code now.
bleakley
approved these changes
Apr 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix for the issue with
arrayDataFrameflickering.The problem was that it's using
wrapPromise.wrapPromiseeffectively usesPromise.resolved(value).then()which means that data has to wait for a microtask to be scheduled on the next event loop tick.I added a new function
wrapResolvedwhich expects a concrete value, and returns aWrappedPromisebut without adding a callback delay. This makesarrayDataFrameand anything using it faster. Without this change, scrolling would flicker unless wrapped in arowCache(which really shouldn't be necessary for an array-backed dataframe).I also changed the signature of
wrapPromisefromPromise<T> | Tto justPromise<T>. This force downstream users to make a choice betweenwrapPromiseandwrapResolved. Users should always choose the faster one, if they can. Should be considered a breaking api change (0.14.0).