I have a custom Lightning Component sitting on a Flexipage for e.g. Account. Now I want to register an handler, which will be invoked each time, the record is updated. Updates might happen via
- standard Record Detail component on the same Flexipage
- other custom components on the same Flexipage
- triggers
What's the best way to detect and handle as many of these updates as possible?
I've tried so far:
<aura:handler name="onUpdated" event="force:recordUpdated"action="{!c.events}" />
<aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.events}"/>
with
events : function(cmp, evt, hlp){
console.log('EVENTS :: ',evt.getName(),evt.getParams());
},
but nothing in the console so far. Any ideas?
Best Answer
Actually I'm using the event force:refreshView which is doing what I want:
and in the controller
If my stuff is making an update, which the flexipage should update on, I'm firing the very same event
Tricky part is, if two components are updating each others: then you have to set a flag or something to prevent endless loops.
Lots of Salesforce Standard components are firing and listening for this event, so it's pretty useful.
Caveats