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

feat: allow component metadata storage #578

Merged
merged 5 commits into from Feb 29, 2024
Merged

Conversation

Traveller23
Copy link
Contributor

Related discussion: #576

After adding this feature, whenever we get the Node, we will also get the custom metadata of the user component. So we were able to automate some of the actions that we previously had to perform manually.
This can bring more configurability to the whole framework.

Copy link

changeset-bot bot commented Nov 10, 2023

🦋 Changeset detected

Latest commit: df0bd8d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@craftjs/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Nov 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
craftjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2024 10:57am

@prevwong
Copy link
Owner

prevwong commented Feb 8, 2024

We can already achieve the same results with the custom prop already, no?

const Component = () => {}

Component.craft => {
  custom: {...}
} 

@Traveller23
Copy link
Contributor Author

Traveller23 commented Feb 8, 2024

We can already achieve the same results with the custom prop already, no?

const Component = () => {}

Component.craft => {
  custom: {...}
} 

There's a difference between customMetadata and custom: the data in custom is saved to the SerializedNode and thus to each instance. The data in customMetadata is shared by all instances of the component, so it doesn't need to be saved to SerializedNode.

Also, since we don't need to serialize customMetadata, we can put methods in there. We've been missing a means to attach methods to components before (and invoke those methods through Node), now we don't have to worry about that with customMetadata.

@prevwong
Copy link
Owner

We can already achieve the same results with the custom prop already, no?

const Component = () => {}

Component.craft => {
  custom: {...}
} 

There's a difference between customMetadata and custom: the data in custom is saved to the SerializedNode and thus to each instance. The data in customMetadata is shared by all instances of the component, so it doesn't need to be saved to SerializedNode.

Also, since we don't need to serialize customMetadata, we can put methods in there. We've been missing a means to attach methods to components before (and invoke those methods through Node), now we don't have to worry about that with customMetadata.

Ah gotcha. Can we rename customMetadata to something like info?

@Traveller23
Copy link
Contributor Author

We can already achieve the same results with the custom prop already, no?

const Component = () => {}

Component.craft => {
  custom: {...}
} 

There's a difference between customMetadata and custom: the data in custom is saved to the SerializedNode and thus to each instance. The data in customMetadata is shared by all instances of the component, so it doesn't need to be saved to SerializedNode.
Also, since we don't need to serialize customMetadata, we can put methods in there. We've been missing a means to attach methods to components before (and invoke those methods through Node), now we don't have to worry about that with customMetadata.

Ah gotcha. Can we rename customMetadata to something like info?

Sure, I'll change it right away.

@Traveller23
Copy link
Contributor Author

@prevwong Done. If any other changes need to be made, just let me know.

Copy link
Owner

@prevwong prevwong left a comment

Choose a reason for hiding this comment

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

Thanks! ❤️

@prevwong prevwong changed the title Allow adding custom metadata to the UserComponent that can be brought into Node feat: allow component metadata storage Feb 21, 2024
@prevwong prevwong merged commit 246fa3c into prevwong:main Feb 29, 2024
2 checks passed
@github-actions github-actions bot mentioned this pull request Feb 21, 2024
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

2 participants