Created
October 20, 2017 00:35
-
-
Save alexed1/512abc577a6efcda2842b79101905304 to your computer and use it in GitHub Desktop.
main component controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
onCometdLoaded : function(component, event, helper) { | |
var cometd = new org.cometd.CometD(); | |
component.set('v.cometd', cometd); | |
if (component.get('v.sessionId') != null) | |
helper.connectCometd(component); | |
}, | |
handleAcceptClick: function(component, event, helper) { | |
}, | |
handleNoThanksClick: function(component, event, helper) { | |
helper.callApex('c.launchFlow', 'successfully called launchFlow', component); | |
}, | |
handleRecordInsightsClick: function(component, event, helper) { | |
component.set('v.showMainPane', false); | |
}, | |
handleSaveInsightsClick: function(component, event, helper) { | |
component.set('v.showMainPane', true); | |
}, | |
doInit : function(component, event, helper) { | |
console.log("inside doinit"); | |
helper.publishRecommendationRequest(component, event, helper); | |
component.set('v.cometdSubscriptions', []); | |
// Disconnect CometD when leaving page | |
window.addEventListener('unload', function(event) { | |
helper.disconnectCometd(component); | |
}); | |
// Retrieve session id | |
var action = component.get('c.getSessionId'); | |
action.setCallback(this, function(response) { | |
if (component.isValid() && response.getState() === 'SUCCESS') { | |
component.set('v.sessionId', response.getReturnValue()); | |
if (component.get('v.cometd') != null) | |
helper.connectCometd(component); | |
} | |
else | |
console.error(response); | |
}); | |
$A.enqueueAction(action); | |
helper.displayToast(component, 'success', 'Ready to receive events.'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment