Lets consider a component Button which is having a function changeName(). Now there is a List ‘ButtonsList’ with a few Button components as its items.
Is there any way I can execute the changeName() function of all the buttons which are children of this ButtonsList ?
Lightning doesn’t have any specific method of executing a function on all children. But the functionality you are after can be easily built yourself.
The most straightforward method is to grab all children (
this.childList) of your ButtonList component, iterate over them and execute your changeName function on each Button instance.
Alternatively you could go the Event emitter route, and emit some kind of “name-change” event that each Button is listening to.