Understanding :
Salesforce introduced a new component lightning:empApi with winter 19 to support streaming API.
Before Winter 19
Prior to winter 19 in order to use the streaming API, we need to upload the CometD javascript libraries, as a static resource. We needed to use cometD by using ltng:require along with afterscriptsloaded .
After Winter 19
But with the new EmpJs Streaming API library which subscribes to a streaming channel and listens to event messages using a shared CometD connection without using the CometD static resource.
This component is supported only in desktop browsers. In addtion, this component provides access to methods for subscribing to a streaming channel and listening to event messages. All streaming channels are supported, including channels for platform events, PushTopic events, generic events, and Change Data Capture events. The lightning:empApi component uses a shared CometD connection.
This example subscribes to a channel when you click the Subscribe button. The channel is specified in an input component. The default value provided is an example platform event channel.
Consider the following code:
Following is the trigger which publishes the event on account update:
Output:
For more details refer to
https://developer.salesforce.com/docs/component-library/bundle/lightning:empApi
Hi Nigam, Not able to find the code in the “Consider the following code:”. Could you please update the post with the code of the implementation.
Hi,
This doesn’t work in Lightning community, but works in LEX. Do you have workaround for communities?
Hi Mayukh …. I would like to ask you, did you find the solution for this using Aura Components? Thanks.