2

I have created & added 4 different components in Lightning page and I want to refresh all of them if any components records get change.

I know that, In order to refresh the specific component we can use $A.get('e.force:refreshView').fire(); event.

but how i can communicate refresh event from one components to another ?

3
  • Does force:refreshView not refresh the complete view? Are you saying the other 3 components are not updating when you trigger force:refreshview event?
    – Rao
    Commented Jul 26, 2017 at 16:49
  • There are indeed some components that do not handle force:refreshView. For example, if you have a custom component that creates a record in a community and also have a standard list view component on the same page, the list view will not listen to the event to update the records in the list after a new one is created. The only workaround we have found is to navigate away then back to force the framework to recreate the list view component.
    – dsharrison
    Commented Jul 26, 2017 at 16:55
  • Yes, force:refreshView is working for one components but not for the other component
    – kiran
    Commented Jul 27, 2017 at 2:27

1 Answer 1

4

You can listen to exact that event in another component, just add a handler:

<aura:handler event="force:refreshView" action="{!c.onRefreshView}" />

As this is an application event all components declaring interest in handling this event will be notified, regardless who is dispatching the refresh view event

5
  • Does this mean that, there has to be one handler for every component to refresh every component inside an app?
    – Rao
    Commented Jul 26, 2017 at 17:07
  • 2
    Yes, every component must register a handler Commented Jul 26, 2017 at 17:29
  • thanks for reply. can you explain how the other components will listen this action="{!c.onRefreshView}" ? can you please provide the example ? thanks
    – kiran
    Commented Jul 27, 2017 at 2:29
  • please post another question, however, i would suggest you read the lightning component developer guide and accept the answer if it helped you. thanks!
    – glls
    Commented Jul 27, 2017 at 2:47
  • Thanks Chris - I got the answer here. developer.salesforce.com/blogs/developer-relations/2015/07/… Intercomponent communication
    – kiran
    Commented Jul 27, 2017 at 3:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .