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

Simpler readOnly field API #780

Open
chrisvxd opened this issue Jan 10, 2025 · 0 comments
Open

Simpler readOnly field API #780

chrisvxd opened this issue Jan 10, 2025 · 0 comments

Comments

@chrisvxd
Copy link
Member

chrisvxd commented Jan 10, 2025

Description

Consider replacing the readOnly functionality of resolveData with a dedicated readOnly API. The current readOnly API:

  1. Requires convoluted dot-notation to set readOnly fields in arrays and objects
  2. Pollutes the Data object

Considerations

  • Should resolveData be renamed resolveProps?
  • Could be folded into the resolveFields API, or perhaps this just provides a second way to implement
  • Storing the readOnly data in the Data object was originally by design, to ensure that the resolver doesn't need to run on page load. However, resolvers now run on page load so this can be reconsidered.
  • How can the API account for making a specific array index readOnly?

Proposals

Proposal 1

A boolean / function API

{
  type: "text",
  readOnly: (props) => {
    return !!props.someOtherValue;
  }
}

or

{
  type: "text",
  readOnly: true
}
@chrisvxd chrisvxd changed the title Simpler readOnly field API Simpler readOnly field API Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant