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

Refactor the Series and Collection data flow #302

Merged
merged 87 commits into from May 8, 2019
Merged

Conversation

evancharlton
Copy link
Contributor

Simplify a lot of the logic in DataProvider by inverting the source of
truth for Series and Collections. This change moves them from immutable
props on DataProvider to separate children components which report their
configuration (through the DataProvider's Context) into DataProvider's
state. This allows DataProvider to be responsible for watching a lot
fewer props and move the logic out to the separate components.

Additionally, this ensures that the properties for Series and Collection
are centrally-documented, due to them using TypeScript for their
implementations. This also comes with some nice syntactic sugar around
the grouping of Series into Collections (however, this is not required).

Another benefit of this cleaned system is that the system can guarantee
that Series and Collection objects which leave DataProvider are
fully-populated. This will allow us to clean up default props littered
throughout the codebase, for things like strokeWidth and color.

Finally, in order to ease this massively-breaking API change, a thin
backwards-compatibility shim has been introduced into DataProvider.
However, this is not intended to be permanent and should be removed
before the 0.5.0 stable version is released.

Evan Charlton added 30 commits May 5, 2019 17:18
Simplify a lot of the logic in DataProvider by inverting the source of
truth for Series and Collections. This change moves them from immutable
props on DataProvider to separate children components which report their
configuration (through the DataProvider's Context) into DataProvider's
state. This allows DataProvider to be responsible for watching a lot
fewer props and move the logic out to the separate components.

Additionally, this ensures that the properties for Series and Collection
are centrally-documented, due to them using TypeScript for their
implementations. This also comes with some nice syntactic sugar around
the grouping of Series into Collections (however, this is not required).

Another benefit of this cleaned system is that the system can guarantee
that Series and Collection objects which leave DataProvider are
fully-populated. This will allow us to clean up default props littered
throughout the codebase, for things like strokeWidth and color.

Finally, in order to ease this massively-breaking API change, a thin
backwards-compatibility shim has been introduced into DataProvider.
However, this is not intended to be permanent and should be removed
before the 0.5.0 stable version is released.
custom accessor support is coming
This required moving the calculated domains into the state
This leads to a crash if there aren't any series at all. Will fix later.
Copy link
Contributor

@valgussev valgussev left a comment

Choose a reason for hiding this comment

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

Overall it became so much better! gj

src/components/DataProvider/index.js Show resolved Hide resolved
src/components/Series/index.tsx Show resolved Hide resolved
src/components/Collection/index.tsx Show resolved Hide resolved
src/components/Scaler/index.tsx Show resolved Hide resolved
@evancharlton evancharlton marked this pull request as ready for review May 6, 2019 12:38
@evancharlton
Copy link
Contributor Author

This is ready for review! Before merging, I'll squash all of these commits into something pretty.

Evan Charlton added 2 commits May 6, 2019 14:56
It should be shared between Series and Collection
Evan Charlton added 5 commits May 6, 2019 15:25
These are already covered by the Scatterplot stories but hey here we go
This required an update to Scaler where we need to handle the series
props changing because they come in late.
@cognite-cicd
Copy link

[pr-server]
The storybook for this PR is hosted on https://griff-react-pr-302.surge.sh

@evancharlton
Copy link
Contributor Author

There is one small known quirk with this PR -- I don't know if it's a regression or not. If you set yDomain for an item (collection or series), and then change it to undefined, it will not clear the value.

I'm tempted to merge this anyway because it's very obscure, and the proper fix is much deeper -- and this PR is sprawling enough as it is.

@evancharlton evancharlton merged commit 7ca395e into master May 8, 2019
@evancharlton evancharlton deleted the series-data-flow branch May 8, 2019 06:50
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.

None yet

3 participants