LPS-129529 Adds the Data representation implementation of Forms to Data Engine #100493
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.
Forwarded from: liferay-forms#167 (Took 1
ci:forward
attempt in 58 seconds)Console
@matuzalemsteles
@liferay-forms
Original pull request comment:
To understand more about the reason for this implementation read the ticket: https://issues.liferay.com/browse/LPS-129529
The
useDataView
hook is the component that ends up doing the entire orchestration of creating the representation of the data, reusing, revalidating, caching, and returning the output of the representation.Key ideas
Some resources make it very valuable and significant for the growth of the application and how it makes it easier for two different structures to coexist but with the same raw data.
dataLayout.dataLayoutPages
there is a great benefit for the implementation of getter, it will be invoked only when it is used, if you only need to get only the title of the page the representation/conversion in the structure ofdataLayoutRows
will not be done, so we have the benefit of creating the lazy representation here.Despite having a lot of good things with this implementation I would say that there is no contraindication just that it adds minimal overhead to the data output which is incredibly small in the 100ns range but that this is a great pros due to the previous implementation that did a lot data conversion all the time which was considerably noticeable at times the slowness.
Design decision
The
useDataView
hook is not used directly, it is built intouseFormState
to avoid coupling its use to the components. The logic is not done on top ofuseFormState
because it is based on principles of responsibility, this helps when all components are using the Data Engine data structure, the swap will be easy to do.Components that already consume useFormState, can already benefit from this.
There may be cases where components consume the data in the Forms and Data Engine structure, although this is not a good practice you can instantiate two useFormState to consume the data in a different way or if the component needs information that does not compare.
Drawbacks
useFormState
to get the data.Notes
✔️ ci:test:stable - 9 out of 9 jobs passed
✔️ ci:test:relevant - 26 out of 26 jobs passed in 2 hours 52 minutes
Click here for more details.
Base Branch:
Branch Name: master
Branch GIT ID: 542ac19ddfbb24263d429cb2041b65f6d8c42f73
Upstream Comparison:
Branch GIT ID: fdde6ad10f71812222a8c02546fa909e3fcc295a
Jenkins Build URL: Acceptance Upstream DXP (master) #1706
ci:test:stable - 9 out of 9 jobs PASSED
9 Successful Jobs:
ci:test:relevant - 26 out of 26 jobs PASSED
26 Successful Jobs:
For more details click here.
✔️ ci:test:sf - 1 out of 1 jobs passed in 4 minutes
Click here for more details.
Base Branch:
Branch Name: master
Branch GIT ID: de28124dfde97c9a709ce440ca1d3965d42fa0f0
Sender Branch:
Branch Name: LPS-129529
1 out of 1jobs PASSEDBranch GIT ID: 0fec386ae193825a9bdbae957ebd59e42539f8ae
1 Successful Jobs:
For more details click here.