-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Table] Batch Child Rendering #1201
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2ea0ecf
Batch child rendering
themadcreator cd67e87
Merge remote-tracking branch 'origin/master' into bd/table-perf
themadcreator 5352057
Use blacklist to reset batcher
themadcreator 12d8675
lint
themadcreator 6cabc56
Merge remote-tracking branch 'origin/master' into bd/table-perf
themadcreator f67337d
Fix tests by reset batcher on state change
themadcreator df28c5a
Merge remote-tracking branch 'origin/master' into bd/table-perf
themadcreator 1752ff1
PR Comments
themadcreator cb9a509
Fix isotest
themadcreator 8d7f506
fix merge issue
themadcreator 3750624
Also batch UPDATES. Add unit test to confirm.
themadcreator 43969bc
Merge remote-tracking branch 'refs/remotes/origin/master' into bd/tab…
themadcreator ee759cc
fix isotest
themadcreator 7b9bece
Fix resize updates. Update test to confirm
themadcreator 9ca216c
lint
themadcreator f14cdf2
Merge remote-tracking branch 'origin/master' into bd/table-perf
themadcreator b8b9e63
Merge remote-tracking branch 'origin/master' into bd/table-perf
themadcreator 9f671dd
PR Comments
themadcreator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PR Comments
- Loading branch information
commit 1752ff1d152ed82689fdbbb61fd7210534ddc240
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,7 @@ | |
|
||
import { requestIdleCallback } from "./requestIdleCallback"; | ||
|
||
export interface IIndex<T> { | ||
[key: string]: T; | ||
} | ||
|
||
export type SimpleStringifyable = string | number | null; | ||
export type SimpleStringifyable = string | number | null | undefined; | ||
|
||
export type Callback = () => void; | ||
|
||
|
@@ -20,17 +16,16 @@ export type Callback = () => void; | |
* | ||
* For example, if your react component has many children, updating them all at | ||
* once may cause jank when reconciling the DOM. This class helps you update | ||
* only a few per frame. | ||
* only a few children per frame. | ||
* | ||
* A typical usage would be: | ||
* | ||
* ```typescript | ||
* | ||
* ```tsx | ||
* public renderChildren = (allChildrenKeys: string[]) => { | ||
* | ||
* batcher.startNewBatch(); | ||
* | ||
* allChildrenKeys.forEach((prop1, index) => { | ||
* allChildrenKeys.forEach((prop1: string, index: number) => { | ||
* batcher.addArgsToBatch(prop1, "prop2", index); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* }); | ||
* | ||
|
@@ -52,8 +47,8 @@ export class Batcher<T> { | |
public static DEFAULT_ADD_LIMIT = 20; | ||
public static DEFAULT_REMOVE_LIMIT = 20; | ||
|
||
private currentObjects: IIndex<T> = {}; | ||
private batchArgs: IIndex<any[]> = {}; | ||
private currentObjects: Record<string, T> = {}; | ||
private batchArgs: Record<string, any[]> = {}; | ||
private done = true; | ||
private callback: Callback; | ||
|
||
|
@@ -86,13 +81,13 @@ export class Batcher<T> { | |
* Compares the set of "batch" arguments to the "current" set. Creates any | ||
* new objects using the callback as a factory. Removes old objects. | ||
* | ||
* Arguments are in the "current" set but were not part of the last "batch" | ||
* set are considered candidates for removal. Similarly, Arguments that are | ||
* part of the "batch" set but not the "current" set are candidates for | ||
* addition. | ||
* Arguments that are in the "current" set but were not part of the last | ||
* "batch" set are considered candidates for removal. Similarly, Arguments | ||
* that are part of the "batch" set but not the "current" set are candidates | ||
* for addition. | ||
* | ||
* The number of objects added and removed maybe limited with the `..Limit` | ||
* parameters. | ||
* The number of objects added and removed may be limited with the | ||
* `...Limit` parameters. | ||
* | ||
* Finally, the batcher determines if the batching is complete if the | ||
* "current" arguments match the "batch" arguments. | ||
|
@@ -156,7 +151,7 @@ export class Batcher<T> { | |
* | ||
* Returns an array of at most `limit` keys. | ||
*/ | ||
private setDifference(a: IIndex<any>, b: IIndex<any>, limit: number) { | ||
private setDifference(a: Record<string, any>, b: Record<string, any>, limit: number) { | ||
const diff = []; | ||
const aKeys = Object.keys(a); | ||
for (let i = 0; i < aKeys.length && limit > 0; i++) { | ||
|
@@ -172,7 +167,7 @@ export class Batcher<T> { | |
/** | ||
* Returns true of objects `a` and `b` have exactly the same keys. | ||
*/ | ||
private setHasSameKeys(a: IIndex<any>, b: IIndex<any>) { | ||
private setHasSameKeys(a: Record<string, any>, b: Record<string, any>) { | ||
const aKeys = Object.keys(a); | ||
const bKeys = Object.keys(b); | ||
if (aKeys.length !== bKeys.length) { | ||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ubernit:
React