[SalesForce] lightning event fired or not

Can we check whether a lightning event of type COMPONENT was fired or not.

I have an event which is handled in parent component with 3 attributes.

Say Ocr,CI,CD..

Now what is happening is these events are fired one at a time and they are getting true or false values based on some condition.

Here when Ocr = true CD,CI are getting undefined and when CD is true Ocr,CI are undefined and CI is true Ocr,CD are undefined. So i need to check if events which are firing 3 times got fired and set some values.

FROM CONSOLE LOG (Ocr,CD,CI are for example purpose)

checkOcr undefined
checkCd true
checkCi undefined

checkOcr undefined
checkCd undefined
checkCi true

checkOcr true
checkCd undefined
checkCi undefined

So when all 3 variables become true then i need to something..I even tried using counter variable but at 2nd time it is initializing the count value again to 0.
Is it possible to check ?

Best Answer

As I understand that you have write aura:handler in parent component and also motioned the action attribute and pass a function of component controller (suppose fireEventHandlerMethod). When ever event will fire controller method will execute.

So, you have create a attribute in parent component like

<aura:attribute name="messageFromEvent" type="Object" default = "{Ocr : false, CI : false, CD : false}"/>

and in the controller method (fireEventHandlerMethod) set the value of messageFromEvent attribute like:

you got Ocr = true from event than you set true to Ocr of messageFromEvent attribute and for other also

messageFromEvent attribute will persist all the values and than you can do some operation on this.

Related Topic