Please tell the difference between setCallBack
and getCallBack
function? Also, If possible can someone please tell me why what is .this function and what does this code is actually doing. (Its related to Instant Notification App https://trailhead.salesforce.com/content/learn/projects/workshop-platform-events/platform-event-subscribe)
const callback = function (message) {
console.log('Event Received : ' + JSON.stringify(message));
helper.onReceiveNotification(component, message);
};
// Subscribe to the channel and save the returned subscription object.
empApi.subscribe(channel, replayId, $A.getCallback(callback)).then($A.getCallback(function (newSubscription) {
console.log('Subscribed to channel ' + channel);
component.set('v.subscription', newSubscription);
}));