10

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?

2 Answers 2

4

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.

3
  • I considered this as well but wanted to see how pure I could keep it. What I have now works until they turn it off. But hopefully by then we have a "blessed" best practice. Commented May 4, 2015 at 14:47
  • @Peter I haven't enabled the App Builder yet, so I will have to check it out. Thanks! Commented May 4, 2015 at 17:23
  • Yeah...it isn't a magic bullet, that VF component. I would much rather go pure LCF if I could. And not even sure it is the way to go, but it is worth a look when approaching feature that LCF just can't do yet.
    – pchittum
    Commented May 4, 2015 at 20:26
6

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.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .