/
DemoEventsController.js
32 lines (26 loc) · 1014 Bytes
/
DemoEventsController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
({
init : function(component, event, helper) {
var empApi = component.find("empApi");
// Error handler function that prints the error to the console.
var errorHandler = function (message) {
console.log("Received error ", message);
}.bind(this);
// Register error listener and pass in the error handler function.
empApi.onError(errorHandler);
var channel='/event/Demo_Event__e';
var sub;
// new events
var replayId=-1;
var callback = function (message) {
component.find('notifLib').showToast({
"title": "Message Received!",
"message": message.data.payload.Message__c
});
}.bind(this);
empApi.subscribe(channel, replayId, callback).then(function(value) {
console.log("Subscribed to channel " + channel);
sub = value;
component.set("v.sub", sub);
});
}
})