Use Streaming API in Lightning Component

You must have faced a situation where you need to refresh your lightning component in order to get the latest values. This problem arises when some other user or process modified the record. Using streaming API, you can subscribe to notification channel and you will get notification, when there is any update on the record.

Definition - Streaming API lets you push a stream of notifications from Salesforce to client apps based on criteria that you define.

First of all, you need to create push topics.

A PushTopic is an sObject that contains the criteria of events you want to listen to, such as data changes for a particular object. You define the criteria as a SOQL query in the PushTopic and specify the record operations to notify on (create, update, delete, and undelete). In addition to event criteria, a PushTopic represents the channel that client apps subscribe to.

Open your Anonymous window and execute below code.

PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'AccountUpdates';
pushTopic.Query = 'SELECT Id, Name, Phone, Rating FROM Account where Rating=\'Hot\'';
pushTopic.ApiVersion = 46.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;