-
Notifications
You must be signed in to change notification settings - Fork 11
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
Wrap returned component data with Readonly #11
Comments
Well matter really doesn't care if you use mutable components. It doesn't really break in any way if you give it a mutable component, you just won't get However, here the issue looks like the issue is not that your component is mutable, but your |
I understand this. Maybe it's better to close this issue, because it's optional to mutate component data. I wish matter had more explicit documentation, like what are requirements to trigger queryChanged (I figured it out through code, but still..) |
If you find a good way to explain this and update the docs, I'm sure a matter PR would be welcome. I think the issue so far has been that there are a few nuances like this that you can technically do but aren't encouraged out of the box. Because of that they can be pretty tricky to explain accurately and concisely for general users and would likely be more confusing. |
Yeah, sure. I just thought what is the purpose of component mutation if it doesn't trigger queryChanged (performance wise it's bad idea). But then I realized that it's very handy to be able mutate existing data. I just wanted some safety, but probably I will just get used to it. You anyway need to call world.insert to trigger queryChanged, so it's not smart to prohibit edit component data (reference types under the keys). |
If you want that safety, you can still type them yourself to ensure you're using your components correctly in the places you want the safety. |
Component data is immutable, but only for first scope. So I can easily edit 2-nd+ scope by accident. Is it by design, or it's impossible to wrap it to Readonly?
Ex:
The text was updated successfully, but these errors were encountered: