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

Remove dataDeepCopy and propertyPassingDeepCopy in favor of non-copy-setData #65

Open
LastLeaf opened this issue Jul 17, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request module:core need discussion Further discussion is needed to decide

Comments

@LastLeaf
Copy link
Member

Currently these two component options are used to control whether the data should be copied while templating. It is component-level options, but it is more practical to control the deep copy strategies of each data field.

We want to remove them in faver of some advanced data update methods.

General API design:

  • add an extra argument for replaceDataOnPath and spliceArrayDataOnPath for the DeepCopyStrategy ;
  • add a new method updateAtomicData to set fields with DeepCopyStrategy.None .
@LastLeaf LastLeaf self-assigned this Jul 17, 2023
@LastLeaf LastLeaf added this to the First Stable Version milestone Jul 17, 2023
@LastLeaf LastLeaf added the enhancement New feature or request label Jul 17, 2023
@LastLeaf
Copy link
Member Author

LastLeaf commented Aug 7, 2023

Need to resolve: how to specify atomic fields in initial data?

@LastLeaf LastLeaf removed this from the v1.0 milestone Jan 22, 2024
@LastLeaf
Copy link
Member Author

We had a discussion today.

  • dataDeepCopy and propertyPassingDeepCopy are simple ways to avoid copy. This should not be removed.
  • They should still default to the current simple-deep-copy strategy to keep the compatibility with the legacy framework.
  • For the partial-deep-copy strategy, we had following strategies to choose.
    1. Just leave it to component writers. It means dataDeepCopy and propertyPassingDeep should be no-copy whenever any field cannot be copied, and other fields should be immutable or manually copied.
    2. Allow any object-typed value to have a special JS symbol to specify how to copy it. This way allows the data provider to control how the data should be copied. It is very powerful, but the component writers can only treat the data as a blackbox and may miss-use it. Also, it requires an extra symbol check on deep-copy objects.
    3. Allow specifying a function which does the copy. It is highly customizable but it totally decoupled from the data provider, which means objects shared between multiple components require the custom copy function everywhere. However, this function can be specified through chaining filters so it may not be difficult to use.
    4. Allow each property specifiying its own property-passing-deep-copy strategy. This still requires the parent component specifying data-deep-copy strategy. This is easy to use and solves many problems, but limit to properties and also decoupled from the data provider.

@LastLeaf LastLeaf added the need discussion Further discussion is needed to decide label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request module:core need discussion Further discussion is needed to decide
Projects
None yet
Development

No branches or pull requests

3 participants