I have an Aura app with a component which initializes nested components. After initializing these, I use this.sandbox.emit to send a message that the children are subscribed to. Unfortunately, the event is emitted before the child components load and it is therefore not received. Is there a way to pass a callback on child initialization?
Note: The event in question is being emitted over and over. It works all except the first time. My debugging has shown me that the issue is that the first occurrence of the event is fired before the child components are initialized. If I delay the first call of showNext() by a second, the first event does work.
I have an Aura app with a component which initializes nested components. After initializing these, I use
this.sandbox.emit
to send a message that the children are subscribed to. Unfortunately, the event is emitted before the child components load and it is therefore not received. Is there a way to pass a callback on child initialization?Here is some sample code:
"parent' component
'child' component
Note: The event in question is being emitted over and over. It works all except the first time. My debugging has shown me that the issue is that the first occurrence of the event is fired before the child components are initialized. If I delay the first call of
showNext()
by a second, the first event does work.Thanks!