reference or Content.getComp....
Suppose I have a 200 sliders, 200 buttons 100 panels..etc..
At several different places in the code, I need to get or set values from some of them
What is best, is it to declare each one of the components or, in those places where I need the values, just get them with
What is best practice? Why?
d.healey last edited by d.healey
It kind of depends on exactly what you're doing.
Generally it's best practice to get references to components up front in on init.
If you need access them without a
constreference then it's best to use
getAllComponentshas less overhead because it doesn't need to assign additional memory.
@d-healey so you're saying that there is no performance or memory difference? Except for the getAllComponents, which is more efficient, less memory demanding?
I try to use getAllComponents as much as possible
d.healey last edited by
so you're saying that there is no performance or memory difference
I'm saying there is a difference between
getAllComponentswhen you are accessing component properties outside of on init.
Without knowing exactly what you're wanting to do it's hard to advise the best approach but if it's outside on init and you don't want to create references inside on init you should use
@d-healey thank you!