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

Turbo: data aggregator #2441

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open

Turbo: data aggregator #2441

wants to merge 52 commits into from

Conversation

scottrippey
Copy link
Member

@scottrippey scottrippey commented Aug 22, 2022

What

This "data aggregator" approach is to replace the Context-based approach currently used by the Turbo refactor.

The problem

Victory components can be nested inside a parent container:

<VictoryChart>
  <VictoryLine data={data} />
  <VictoryBar data={data} />
  <VictoryScatter data={data} />
</VictoryChart>

The parent container, in this example, needs to aggregate all the data from the children, to determine the range, domain, scale, etc.

In the current Turbo refactor, we did this via Context; each child reports its data to the parent. This happens in a useLayoutEffect, which suffers from major drawbacks -- primarily that it breaks SSR support.

The "Data Aggregator" Approach

This approach is derived from Victory's pre-Turbo behavior. When a parent is rendered, it will actually traverse the children and aggregate all data before rendering.
This works with SSR, and prevents unneeded rerendering.

This also gives us a chance to normalize the data, and provide a simple API for accessing "normalized" data.

@scottrippey scottrippey marked this pull request as draft August 22, 2022 23:07
scottrippey added 27 commits August 23, 2022 11:39
@carbonrobot
Copy link
Contributor

@scottrippey Do we have additional work to do here?

@scottrippey
Copy link
Member Author

@carbonrobot This PoC is complete. The approach worked great, but this only applies to the turbo refactor. I suggest we get this merged, as it vastly improves the turbo codebase. Then we can decide what to do with it along with the rest of turbo.

@scottrippey scottrippey changed the title [WIP] Turbo: data aggregator Turbo: data aggregator Nov 16, 2023
@scottrippey scottrippey marked this pull request as ready for review November 16, 2023 14:37
test/jest-config.js Show resolved Hide resolved
package.json Show resolved Hide resolved
Copy link
Contributor

@carbonrobot carbonrobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update and sync the pnpm merge conflict?

Copy link

vercel bot commented Nov 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
victory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 16, 2023 9:40pm

Copy link

changeset-bot bot commented Nov 16, 2023

⚠️ No Changeset found

Latest commit: d0e93fd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants