-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
[core] Move away for the event system to trigger pipe processings #4378
Conversation
These are the results for the performance tests:
|
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.
No problem pushing this forward. I think we should still avoid calling unstable_requestPipeProcessorsApplication
as much as possible, to not cause an additional rerender. The features should be designed to be resilient when the model contains invalid data, e.g. missing columns.
Yes |
Extracted from #4208
This PR only impacts the pipe processing which are triggered when
GridEvents.columnsChange
is fired. Pipe processing lilkecolumnMenu
orscrollToIndexes
are not impacted.Current behavior for processors
GridEvents.pipeProcessorRegister
and re-apply the processors whenever this event is fired on the right groupA problem appears when we want to re-apply the processors but none of the deps of the processor have changed.
For instance in the row grouping, we want to re-apply
hydrateColumns
when the columns in a way which changes the sanitizedrowGroupingModel
.If we just use
gridRowGroupingSanitizedModelSelector
in the render ofuseGridRowGroupingProcessors
to update the deps of the processor, then we would have two problems:hydrateColumns
, creating an infinite loopThe current hack to listen to
GridEvents.columnsChange
and to fire manuallyhydrateColumns
by callingapiRef.current.updateColumns([])
.This hacky solutions works and re-apply
hydrateColumns
synchronously when the columns are updated in a way that changes the sanitizedrowGroupingModel
.Why do we need to fix it ?
For the aggregation, I need to do something similar.
When the columns changes, I need to re-apply:
hydrateColumns
to wrap / unwrap the aggregated columns (the same hack can be used)hydrateRows
(a new pipe processing that adds rows and is used by the aggregation to create the footers)The same hack can't be used for
hydrateRows
.If I call
apiRef.current.updateRows([])
, the update of the state is throttled which is problematic here.I could create a new
apiRef.current.unstable_syncUpdateRows
, but I think it is worth cleaning the pattern rather than creating more dirt.The solution
For the processors
I introduced a new method
unstable_requestPipeProcessorsApplication
which aims at firing the appliers of a group imperatively.For the appliers
Instead of listening to
GridEvents.pipeProcessorRegister
to re-apply their logic, plugins can now useuseGridRegisterPipeApplier
to give a callback which will be automatically be calledGridEvents.pipeProcessorRegister
)apiRef.current.unstable_requestPipeProcessorsApplication
is called#4322 will document in detail this behavior