empApi with Lightning Web Components?Lightning web components issue with SFDX push and pullLightning Web Components Easy Spaces sample application LWC component codeTarget inner elements of standard Lightning Web Components with CSS@track vs @api (Lightning Web Components)Error when adding different Lightning Web Components to the PlaygroundInvoking LWC component from a plain URL - Read URL Parameter inside LWCHow to create a Lightning Web Component without Salesforce DX?Lightning Web Components - Custom Decorator supportLightning Web Components licence fee
Features of a Coda section
if the mode of a normal distribution is 0, then what's the value of the mean
Multiple devices with one IPv6 to the Internet?
Illustrator - Removing the blank space below a letter
Meaning of 'off one's brake fluid'
Run "cd" command as superuser in Linux
Is it possible to have a healthy work-life balance as a professor?
Where do overtones in a 555 generated square wave come from?
Can I select any of my published paper in journal for book chapter
How offensive is Fachidiot?
How does an aircraft descend without its nose pointing down?
What is a word for the feeling of constantly wanting new possessions?
I can be found near gentle green hills and stony mountains
How to initiate a conversation with a person who recently had transition but you were not in touch with them?
Are the Properties of the EM Spectrum Fluid?
18-month-old kicked out of church nursery
Continents with simplex noise
indent and noindent: details from Knuth's The TeXbook
Why can't I book this multi-city fare on American Airlines?
Which verb means "to pet <an animal>"?
Has any version of Marvel's Black Panther ever been able to actually turn into a Were-Panther form?
Computationally expensive AI techniques (that are promising)
Did Bercow say he would have sent the EU extension-request letter himself, had Johnson not done so?
Could an adjective be used like an adverb in Latin?
empApi with Lightning Web Components?
Lightning web components issue with SFDX push and pullLightning Web Components Easy Spaces sample application LWC component codeTarget inner elements of standard Lightning Web Components with CSS@track vs @api (Lightning Web Components)Error when adding different Lightning Web Components to the PlaygroundInvoking LWC component from a plain URL - Read URL Parameter inside LWCHow to create a Lightning Web Component without Salesforce DX?Lightning Web Components - Custom Decorator supportLightning Web Components licence fee
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I have an LWC in which I want to use EMP API. Docs say that's only currently available in Aura. Do I have to wrap my entire LWC in aura in order to add the EMP API, or can I create a utility aura component and do pub-sub to/from the LWC?
lightning-web-components streaming-api platform-event
add a comment
|
I have an LWC in which I want to use EMP API. Docs say that's only currently available in Aura. Do I have to wrap my entire LWC in aura in order to add the EMP API, or can I create a utility aura component and do pub-sub to/from the LWC?
lightning-web-components streaming-api platform-event
Adding to all the answers. I have created a library for the lightning web component to use streaming api. It does work in LWC, Aura and mobile app as well. github.com/TheVishnuKumar/lwc-streaming-api Note: I am using this in the live project for desktop and mobile app both.
– Vishnu Kumar
Jul 9 at 2:51
add a comment
|
I have an LWC in which I want to use EMP API. Docs say that's only currently available in Aura. Do I have to wrap my entire LWC in aura in order to add the EMP API, or can I create a utility aura component and do pub-sub to/from the LWC?
lightning-web-components streaming-api platform-event
I have an LWC in which I want to use EMP API. Docs say that's only currently available in Aura. Do I have to wrap my entire LWC in aura in order to add the EMP API, or can I create a utility aura component and do pub-sub to/from the LWC?
lightning-web-components streaming-api platform-event
lightning-web-components streaming-api platform-event
asked Jun 8 at 17:25
PatMcClellan__cPatMcClellan__c
1,3908 silver badges26 bronze badges
1,3908 silver badges26 bronze badges
Adding to all the answers. I have created a library for the lightning web component to use streaming api. It does work in LWC, Aura and mobile app as well. github.com/TheVishnuKumar/lwc-streaming-api Note: I am using this in the live project for desktop and mobile app both.
– Vishnu Kumar
Jul 9 at 2:51
add a comment
|
Adding to all the answers. I have created a library for the lightning web component to use streaming api. It does work in LWC, Aura and mobile app as well. github.com/TheVishnuKumar/lwc-streaming-api Note: I am using this in the live project for desktop and mobile app both.
– Vishnu Kumar
Jul 9 at 2:51
Adding to all the answers. I have created a library for the lightning web component to use streaming api. It does work in LWC, Aura and mobile app as well. github.com/TheVishnuKumar/lwc-streaming-api Note: I am using this in the live project for desktop and mobile app both.
– Vishnu Kumar
Jul 9 at 2:51
Adding to all the answers. I have created a library for the lightning web component to use streaming api. It does work in LWC, Aura and mobile app as well. github.com/TheVishnuKumar/lwc-streaming-api Note: I am using this in the live project for desktop and mobile app both.
– Vishnu Kumar
Jul 9 at 2:51
add a comment
|
2 Answers
2
active
oldest
votes
Summer 19 is 1 week away, but that won't stop you from preparing it beforehand in your Summer 19 Sandbox or Scratch org.
lightning:empApi does not show LWC button as enabled as its referring to the Spring version of docs.
Also , the release notes dont tell us about how to use empAPI in LWC. I could not find any public documentation on about how to use it.
A quick way to refer docs of lwc is Summer 19 org is to visit the url
https://yourSummer19org.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
Sample Example :
<template>
<lightning-card title="EmpApi Example" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<p>Use the buttons below to subscribe and unsubscribe to a streaming channel!</p>
<lightning-input label="Channel Name" value=channelName
onchange=handleChannelName></lightning-input>
<lightning-button variant="success" label="Subscribe" title="Subscribe"
onclick=handleSubscribe disabled=isSubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="destructive" label="Unsubscribe" title="Unsubscribe"
onclick=handleUnsubscribe disabled=isUnsubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
</div>
</lightning-card>
</template>
JS:
import LightningElement, track from 'lwc';
import subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled from 'lightning/empApi';
export default class EmpApiLWC extends LightningElement
@track channelName = '/event/Test__e';
@track isSubscribeDisabled = false;
@track isUnsubscribeDisabled = !this.isSubscribeDisabled;
subscription = ;
// Tracks changes to channelName text field
handleChannelName(event)
this.channelName = event.target.value;
// Handles subscribe button click
handleSubscribe()
// Callback invoked whenever a new event message is received
const messageCallback = function(response)
console.log('New message received : ', JSON.stringify(response));
// Response contains the payload of the new message received
;
// Invoke subscribe method of empApi. Pass reference to messageCallback
subscribe(this.channelName, -1, messageCallback).then(response =>
// Response contains the subscription information on successful subscribe call
console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
this.subscription = response;
this.toggleSubscribeButton(true);
);
// Handles unsubscribe button click
handleUnsubscribe()
this.toggleSubscribeButton(false);
// Invoke unsubscribe method of empApi
unsubscribe(this.subscription, response =>
console.log('unsubscribe() response: ', JSON.stringify(response));
// Response is true for successful unsubscribe
);
toggleSubscribeButton(enableSubscribe)
this.isSubscribeDisabled = enableSubscribe;
this.isUnsubscribeDisabled = !enableSubscribe;
registerErrorListener()
// Invoke onError empApi method
onError(error =>
console.log('Received error from server: ', JSON.stringify(error));
// Error contains the server-side error
);
add a comment
|
How about option 3: Wait a week.
According to the release notes, EmpApi is currently slated to go live in LWC for Summer 19.
1
Yeah, they specifically referenced it in the release webinar yesterday (June 7th)
– BritishBoyinDC
Jun 8 at 18:57
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f265230%2fempapi-with-lightning-web-components%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Summer 19 is 1 week away, but that won't stop you from preparing it beforehand in your Summer 19 Sandbox or Scratch org.
lightning:empApi does not show LWC button as enabled as its referring to the Spring version of docs.
Also , the release notes dont tell us about how to use empAPI in LWC. I could not find any public documentation on about how to use it.
A quick way to refer docs of lwc is Summer 19 org is to visit the url
https://yourSummer19org.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
Sample Example :
<template>
<lightning-card title="EmpApi Example" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<p>Use the buttons below to subscribe and unsubscribe to a streaming channel!</p>
<lightning-input label="Channel Name" value=channelName
onchange=handleChannelName></lightning-input>
<lightning-button variant="success" label="Subscribe" title="Subscribe"
onclick=handleSubscribe disabled=isSubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="destructive" label="Unsubscribe" title="Unsubscribe"
onclick=handleUnsubscribe disabled=isUnsubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
</div>
</lightning-card>
</template>
JS:
import LightningElement, track from 'lwc';
import subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled from 'lightning/empApi';
export default class EmpApiLWC extends LightningElement
@track channelName = '/event/Test__e';
@track isSubscribeDisabled = false;
@track isUnsubscribeDisabled = !this.isSubscribeDisabled;
subscription = ;
// Tracks changes to channelName text field
handleChannelName(event)
this.channelName = event.target.value;
// Handles subscribe button click
handleSubscribe()
// Callback invoked whenever a new event message is received
const messageCallback = function(response)
console.log('New message received : ', JSON.stringify(response));
// Response contains the payload of the new message received
;
// Invoke subscribe method of empApi. Pass reference to messageCallback
subscribe(this.channelName, -1, messageCallback).then(response =>
// Response contains the subscription information on successful subscribe call
console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
this.subscription = response;
this.toggleSubscribeButton(true);
);
// Handles unsubscribe button click
handleUnsubscribe()
this.toggleSubscribeButton(false);
// Invoke unsubscribe method of empApi
unsubscribe(this.subscription, response =>
console.log('unsubscribe() response: ', JSON.stringify(response));
// Response is true for successful unsubscribe
);
toggleSubscribeButton(enableSubscribe)
this.isSubscribeDisabled = enableSubscribe;
this.isUnsubscribeDisabled = !enableSubscribe;
registerErrorListener()
// Invoke onError empApi method
onError(error =>
console.log('Received error from server: ', JSON.stringify(error));
// Error contains the server-side error
);
add a comment
|
Summer 19 is 1 week away, but that won't stop you from preparing it beforehand in your Summer 19 Sandbox or Scratch org.
lightning:empApi does not show LWC button as enabled as its referring to the Spring version of docs.
Also , the release notes dont tell us about how to use empAPI in LWC. I could not find any public documentation on about how to use it.
A quick way to refer docs of lwc is Summer 19 org is to visit the url
https://yourSummer19org.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
Sample Example :
<template>
<lightning-card title="EmpApi Example" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<p>Use the buttons below to subscribe and unsubscribe to a streaming channel!</p>
<lightning-input label="Channel Name" value=channelName
onchange=handleChannelName></lightning-input>
<lightning-button variant="success" label="Subscribe" title="Subscribe"
onclick=handleSubscribe disabled=isSubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="destructive" label="Unsubscribe" title="Unsubscribe"
onclick=handleUnsubscribe disabled=isUnsubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
</div>
</lightning-card>
</template>
JS:
import LightningElement, track from 'lwc';
import subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled from 'lightning/empApi';
export default class EmpApiLWC extends LightningElement
@track channelName = '/event/Test__e';
@track isSubscribeDisabled = false;
@track isUnsubscribeDisabled = !this.isSubscribeDisabled;
subscription = ;
// Tracks changes to channelName text field
handleChannelName(event)
this.channelName = event.target.value;
// Handles subscribe button click
handleSubscribe()
// Callback invoked whenever a new event message is received
const messageCallback = function(response)
console.log('New message received : ', JSON.stringify(response));
// Response contains the payload of the new message received
;
// Invoke subscribe method of empApi. Pass reference to messageCallback
subscribe(this.channelName, -1, messageCallback).then(response =>
// Response contains the subscription information on successful subscribe call
console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
this.subscription = response;
this.toggleSubscribeButton(true);
);
// Handles unsubscribe button click
handleUnsubscribe()
this.toggleSubscribeButton(false);
// Invoke unsubscribe method of empApi
unsubscribe(this.subscription, response =>
console.log('unsubscribe() response: ', JSON.stringify(response));
// Response is true for successful unsubscribe
);
toggleSubscribeButton(enableSubscribe)
this.isSubscribeDisabled = enableSubscribe;
this.isUnsubscribeDisabled = !enableSubscribe;
registerErrorListener()
// Invoke onError empApi method
onError(error =>
console.log('Received error from server: ', JSON.stringify(error));
// Error contains the server-side error
);
add a comment
|
Summer 19 is 1 week away, but that won't stop you from preparing it beforehand in your Summer 19 Sandbox or Scratch org.
lightning:empApi does not show LWC button as enabled as its referring to the Spring version of docs.
Also , the release notes dont tell us about how to use empAPI in LWC. I could not find any public documentation on about how to use it.
A quick way to refer docs of lwc is Summer 19 org is to visit the url
https://yourSummer19org.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
Sample Example :
<template>
<lightning-card title="EmpApi Example" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<p>Use the buttons below to subscribe and unsubscribe to a streaming channel!</p>
<lightning-input label="Channel Name" value=channelName
onchange=handleChannelName></lightning-input>
<lightning-button variant="success" label="Subscribe" title="Subscribe"
onclick=handleSubscribe disabled=isSubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="destructive" label="Unsubscribe" title="Unsubscribe"
onclick=handleUnsubscribe disabled=isUnsubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
</div>
</lightning-card>
</template>
JS:
import LightningElement, track from 'lwc';
import subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled from 'lightning/empApi';
export default class EmpApiLWC extends LightningElement
@track channelName = '/event/Test__e';
@track isSubscribeDisabled = false;
@track isUnsubscribeDisabled = !this.isSubscribeDisabled;
subscription = ;
// Tracks changes to channelName text field
handleChannelName(event)
this.channelName = event.target.value;
// Handles subscribe button click
handleSubscribe()
// Callback invoked whenever a new event message is received
const messageCallback = function(response)
console.log('New message received : ', JSON.stringify(response));
// Response contains the payload of the new message received
;
// Invoke subscribe method of empApi. Pass reference to messageCallback
subscribe(this.channelName, -1, messageCallback).then(response =>
// Response contains the subscription information on successful subscribe call
console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
this.subscription = response;
this.toggleSubscribeButton(true);
);
// Handles unsubscribe button click
handleUnsubscribe()
this.toggleSubscribeButton(false);
// Invoke unsubscribe method of empApi
unsubscribe(this.subscription, response =>
console.log('unsubscribe() response: ', JSON.stringify(response));
// Response is true for successful unsubscribe
);
toggleSubscribeButton(enableSubscribe)
this.isSubscribeDisabled = enableSubscribe;
this.isUnsubscribeDisabled = !enableSubscribe;
registerErrorListener()
// Invoke onError empApi method
onError(error =>
console.log('Received error from server: ', JSON.stringify(error));
// Error contains the server-side error
);
Summer 19 is 1 week away, but that won't stop you from preparing it beforehand in your Summer 19 Sandbox or Scratch org.
lightning:empApi does not show LWC button as enabled as its referring to the Spring version of docs.
Also , the release notes dont tell us about how to use empAPI in LWC. I could not find any public documentation on about how to use it.
A quick way to refer docs of lwc is Summer 19 org is to visit the url
https://yourSummer19org.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
Sample Example :
<template>
<lightning-card title="EmpApi Example" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<p>Use the buttons below to subscribe and unsubscribe to a streaming channel!</p>
<lightning-input label="Channel Name" value=channelName
onchange=handleChannelName></lightning-input>
<lightning-button variant="success" label="Subscribe" title="Subscribe"
onclick=handleSubscribe disabled=isSubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="destructive" label="Unsubscribe" title="Unsubscribe"
onclick=handleUnsubscribe disabled=isUnsubscribeDisabled
class="slds-m-left_x-small"></lightning-button>
</div>
</lightning-card>
</template>
JS:
import LightningElement, track from 'lwc';
import subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled from 'lightning/empApi';
export default class EmpApiLWC extends LightningElement
@track channelName = '/event/Test__e';
@track isSubscribeDisabled = false;
@track isUnsubscribeDisabled = !this.isSubscribeDisabled;
subscription = ;
// Tracks changes to channelName text field
handleChannelName(event)
this.channelName = event.target.value;
// Handles subscribe button click
handleSubscribe()
// Callback invoked whenever a new event message is received
const messageCallback = function(response)
console.log('New message received : ', JSON.stringify(response));
// Response contains the payload of the new message received
;
// Invoke subscribe method of empApi. Pass reference to messageCallback
subscribe(this.channelName, -1, messageCallback).then(response =>
// Response contains the subscription information on successful subscribe call
console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
this.subscription = response;
this.toggleSubscribeButton(true);
);
// Handles unsubscribe button click
handleUnsubscribe()
this.toggleSubscribeButton(false);
// Invoke unsubscribe method of empApi
unsubscribe(this.subscription, response =>
console.log('unsubscribe() response: ', JSON.stringify(response));
// Response is true for successful unsubscribe
);
toggleSubscribeButton(enableSubscribe)
this.isSubscribeDisabled = enableSubscribe;
this.isUnsubscribeDisabled = !enableSubscribe;
registerErrorListener()
// Invoke onError empApi method
onError(error =>
console.log('Received error from server: ', JSON.stringify(error));
// Error contains the server-side error
);
answered Jun 10 at 8:58
Pranay JaiswalPranay Jaiswal
24.9k5 gold badges36 silver badges78 bronze badges
24.9k5 gold badges36 silver badges78 bronze badges
add a comment
|
add a comment
|
How about option 3: Wait a week.
According to the release notes, EmpApi is currently slated to go live in LWC for Summer 19.
1
Yeah, they specifically referenced it in the release webinar yesterday (June 7th)
– BritishBoyinDC
Jun 8 at 18:57
add a comment
|
How about option 3: Wait a week.
According to the release notes, EmpApi is currently slated to go live in LWC for Summer 19.
1
Yeah, they specifically referenced it in the release webinar yesterday (June 7th)
– BritishBoyinDC
Jun 8 at 18:57
add a comment
|
How about option 3: Wait a week.
According to the release notes, EmpApi is currently slated to go live in LWC for Summer 19.
How about option 3: Wait a week.
According to the release notes, EmpApi is currently slated to go live in LWC for Summer 19.
answered Jun 8 at 17:32
pchittumpchittum
15.6k4 gold badges44 silver badges90 bronze badges
15.6k4 gold badges44 silver badges90 bronze badges
1
Yeah, they specifically referenced it in the release webinar yesterday (June 7th)
– BritishBoyinDC
Jun 8 at 18:57
add a comment
|
1
Yeah, they specifically referenced it in the release webinar yesterday (June 7th)
– BritishBoyinDC
Jun 8 at 18:57
1
1
Yeah, they specifically referenced it in the release webinar yesterday (June 7th)
– BritishBoyinDC
Jun 8 at 18:57
Yeah, they specifically referenced it in the release webinar yesterday (June 7th)
– BritishBoyinDC
Jun 8 at 18:57
add a comment
|
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f265230%2fempapi-with-lightning-web-components%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Adding to all the answers. I have created a library for the lightning web component to use streaming api. It does work in LWC, Aura and mobile app as well. github.com/TheVishnuKumar/lwc-streaming-api Note: I am using this in the live project for desktop and mobile app both.
– Vishnu Kumar
Jul 9 at 2:51