You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider returning reference type from AddComponent API #2162
Hi Safia Abdalla (@captainsafia)
We do have constructors overloads that are internal at the moment and would allow you to pass the source schema directly.
Effectively allowing you to write something like this
I think it'd be preferable to separate the two concerns, and offer something like that instead.
Why do you think its preferable to separate?
IMO, having the AddComponent API makes it a little easier to connect the fact that the object that is inserted into a Schema property is a reference to the thing that was added to components. The two concepts seem linked in that way to me.
One might want to create multiple references to the same component.
One might not want to create the reference at the same time the component is added, in which case the allocation is wasted (depending on how we model the overloads)
Activity
baywet commentedon Feb 24, 2025
Hi Safia Abdalla (@captainsafia)
We do have constructors overloads that are internal at the moment and would allow you to pass the source schema directly.
Effectively allowing you to write something like this
I'm not saying this would be better than your proposal, just stating it's a possibility.
I think it'd be preferable to separate the two concerns, and offer something like that instead.
(which would return a value or throw, we could also have a TryGet variant)
what do you think?
captainsafia commentedon Feb 24, 2025
Why do you think its preferable to separate?
IMO, having the
AddComponentAPI makes it a little easier to connect the fact that the object that is inserted into a Schema property is a reference to the thing that was added to components. The two concepts seem linked in that way to me.baywet commentedon Feb 25, 2025
Because: