I need to detect record-updates by different sources as stated here: Lightning Components: how to use events to detect record updates?
For this example, I’m using the standard Record Detail compo on a Flexipage.
I don’t like it, but unfortunately the only viable approach seems to handle the force:refreshView seem to be the only way to detect updates. I handle them like like that:
Markup
<aura:handler event="force:refreshView" action="{!c.events}" />
Controller
events : function(cmp, evt, hlp){ console.log('HANDLER'); },
Result
Now ‘HANDLER’ appears exactly 4 times in my console per subscribing component I have on the Flexipage. Why that?
Expected
Each handler should get called once per subscribing component.
Answer
Only workaround I found so far is building a throttle
<aura:attribute name="refreshTimestamp" type="Integer" default="0" />
forceRefreshViewHandler : function(cmp, evt, hlp){
var lastRefresh = cmp.get("v.refreshTimestamp")
if( hlp.ts() - lastRefresh > 1000 ) {
// doing my stuff here
cmp.set("v.refreshTimestamp" , hlp.ts() );
}
}
The standard component is hammering usually it’s 4 bullets within less than 50ms so it seems to work. But hackish as hell and still no explanation why it’s necessary at all.
Attribution
Source : Link , Question Author : Uwe Heim , Answer Author : Uwe Heim