I want a functionality which automatically refreshes a lightning page when there is a update in the object record details. I'm trying with Streaming API to achieve this. But the page is not refreshed whenever there is a update in the record. Please let me know what else I need to add to make it work.

Here are the details.


PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'QueueUpdates1';
pushTopic.Query = 'SELECT Id, Name, AgentsAvailable__c FROM Queue_Status__c';
pushTopic.ApiVersion = 36.0;
insert pushTopic;

 <lightning:empApi aura:id="empApi"/>
 <aura:handler name="init" value="{!this}" action="{!c.onInit}"/>


  onInit: function(component, event, helper) {        
        var action = component.get("c.getQueues");

        action.setCallback(this, function(response){
            if(response.getState()==="SUCCESS" && component.isValid()){

        const empApi = component.find('empApi');
        const channel = '/topic/QueueUpdates5';
        var handleError = function (error) {
            console.log('empApi error', error);

        empApi.subscribe(channel, -1, $A.getCallback(eventReceived => {
            console.log('Received event ', JSON.stringify(eventReceived));


The problem here was : I was using my component in a standalone app , but empApi won't work with a standalone app . I added it to lightning experience (sales cloud) as per answers/comments mentioned in Lightning Component empAPI in LightningApp and it is working fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.