function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vance Kessler 23Vance Kessler 23 

Invisible components responding to force:refreshView

I noticed that components respond to the force:refreshView event long after they have been removed from view. I wrote some test components that I placed on the Contact, Account, and Opportunity related list pages. If I navigate to a record of each type, they all continue to respond to the refreshView event. In fact, if I navigate to different accounts or contacts, each one continues to repsond to the refreshView event. I have found that it keeps a maximum of 4 components active in the background before actually destroying (unrendering) them.

In some components, we reload data on the refreshView event. Is there a way to know that reload of data is a waste of time?

Here is my test contact component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
    <aura:handler event="force:refreshView" action="{!c.refreshData}" />
    <ui:button label="Fire" press="{!c.buttonClick}" class="slds-button slds-button--neutral" />

    buttonClick : function(component, event, helper) {
    refreshData : function(component, event, helper) {
        alert('Contact data refreshed');

The other components simply have the alert text change to reflect the location of the component.
Vance Kessler 23Vance Kessler 23
According to the SF development team, this is expected behavior. I can sort of understand why. If you switch away from a tab and the refresh event is raised, that tab needs to be updated in case it is displayed again.

What I do NOT understand, is why this event is raised for components after the current record is navigated away from. We are hitting the 100-SOQL-query limit because of this bug. There needs to be an event that is raised when a component is removed from view or the component should be destroyed immediately.

I created an Idea for this