I’m trying to convert a Visualforce/Angular app into a Lightning app, which has translated well so far. The last hurdle is to utilize the Streaming API to track updates. I haven’t found any samples and am wondering if this is possible. Or is it another case where Lightning security restrictions are limiting access, at least for now.
It looks like it is possible in Salesforce1, as evident of callouts by cometd. However, I’m not sure if that is accessible to developers. In particular I’m unclear on how to get the session Id that the tutorials for visualforce reference via the global variable ($Api).
If it is possible, could someone point me to an example?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
As an interim have you considered a composite App Builder app?
App builder has the ability to include a Visualforce page. In certain use cases, you could rely upon the VF page component in App Builder to surface the data pushed out by Streaming API. While the rest of the app could be built using Lightning Components.
I don’t know what your app is, or if this would work for you, but for some, at least while we wait for more features to get brought on line for LC, this could be a solution.
I have it working with a lightning component. The deal with the $Api variable is that it is not available. BUT in my component I have a up:inputText hidden via CSS that I store the sessionId in. In my doInit function I call some apex to return UserInfo.getSessionId()
I am working on a blog entry for that now as well but it’s not complete as I just got it working on Monday and have been on vacation.
Also had issues updating some of my components but reverted to document.getElementById to locate and update values. Jquery wasn’t working for finding and setting the text and aura:id doesn’t seem to support dynamic expressions to make them unique. There’s a globalId that you can use but that didn’t do it either.
In the end it was a combo of lightning and HTML that did it.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0