SlideShare a Scribd company logo
Lightning Message Service
@pchittum | pchittum@salesforce.com
Peter Chittum, Sr Director Developer Evangelism
Forward-Looking Statement
Statement under the Private Securities Litigation Reform Act of 1995:
This presentation contains forward-looking statements about the company’s financial and operating results, which may include expected GAAP and non-GAAP financial and other operating
and non-operating results, including revenue, net income, diluted earnings per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected
current remaining performance obligation growth, expected tax rates, the one-time accounting non-cash charge that was incurred in connection with the Salesforce.org combination; stock-
based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth and sustainability goals. The achievement or success of the matters covered by
such forward-looking statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s
results could differ materially from the results expressed or implied by the forward-looking statements we make.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of geopolitical events;
the impact of foreign currency exchange rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading
provider of enterprise cloud computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the
competitive nature of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our
customer base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with new data centers and third-party infrastructure providers; additional data center capacity; real estate
and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market; our strategy of
acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair value of our investments in
complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and investments; the impact of future gains
or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly traded companies within the company's strategic
investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies, including delays related to the integration of
Tableau due to regulatory review by the United Kingdom Competition and Markets Authority; our ability to continue to grow unearned revenue and remaining performance obligation; our
ability to protect our intellectual property rights; our ability to develop our brands; our reliance on third-party hardware, software and platform providers; our dependency on the development
and maintenance of the infrastructure of the Internet; the
effect of evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the potential
availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax
rate; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our outstanding debt, revolving credit facility, term loan and
loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes with the
Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s website at
www.salesforce.com/investor.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.
Agenda
Intro to LMS
Demo
Footer
Principles of Message Service
Client-side event bus between DOM branches
LWC, Aura, and Visualforce as Equal Citizens
Don't Be Surprising (Scope)
Communication between DOM Branches
LMS Lightning Message Service
LWC, Aura, Visualforce as Equal Citizens
Demo
Context
Distinguish between different near-root level DOM features
Scope
Whether a subscriber remains active when its context becomes inactive
Resources
Learn MOAR Summer 20 Release blog: https://bit.ly/lms-launch-blog
Follow the work in this github issue: https://bit.ly/lms-recipe-issue
Scoped Messaging example: https://bit.ly/lms-with-scope
LMS Lightning Message Service
Appendix A: All The Samples
Where can I go to find other resources to learn about
LMS (apart from the docs, of course)
Internal LMS Example Inventory
LWC Recipes Sample App
● LWC Publisher
● LWC Subscriber
● Aura Publisher
● Aura Subscriber
● VF Publisher
○ Page and Static Resource
● VF Subscriber (with postback)
○ Page and Static Resource
● VF Subscriber (with remote obj)
○ Page and Static Resource
E-Bikes Sample App
● productTileList
● productCard
● productFilter
Dreamhouse Sample App
● propertySummary
● daysOnMarket
● propertyFilter
● propertyMap
● propertyTileList
Easy Spaces Sample App
● reservationHelper
● reservationList
● customerList
● spaceDesigner
Trailhead Modules and Projects
● Build a Bear-Tracking App with Lightning
Web Components Project
Appendix: the LMS APIs
A summary of interacting with LMS across all three
Salesforce UI technologies: LWC, Aura, Visualforce
LMS Moving Parts
The message service: the reusable parts, used to publish, subscribe, etc.
The message channel: a way to name and segment messages
(Note: for all examples we're using the recipes in the LWC Recipes sample app)
The above message channel would be referenced as Record_Selected__c in code
Message Channel Metadata
Definining a Message Channel
Import via ES6 modules
import { subscribe, publish, MessageContext } from 'lightning/messageService';
import RECORD_SELECTED_CHANNEL from '@salesforce/messageChannel/Record_Selected__c';
LMS in LWC
MessageService imports
● publish
● subscribe
● unsubscribe
● MessageContext
● APPLICATION_SCOPE
Message Channel
● Surfaced as an ES6 module by API name
in the @salesforce module scope
● Use default import syntax
export default class LmsPublisherWebComponent extends LightningElement {
@wire(getContactList)
contacts;
@wire(MessageContext)
messageContext;
// Respond to UI event by publishing message
handleContactSelect(event) {
const payload = { recordId: event.target.contact.Id };
publish(this.messageContext, RECORD_SELECTED_CHANNEL, payload);
}
}
In LWC
Publishing a Message
export default class LmsSubscriberWebComponent extends LightningElement {
subscription = null;
...
@wire(MessageContext)
messageContext;
...
subscribeToMessageChannel() {
this.subscription = subscribe(
this.messageContext,
RECORD_SELECTED_CHANNEL,
(message) => this.handleMessage(message)
);
}
...
connectedCallback() {
this.subscribeToMessageChannel();
}
In LWC
Subscribing to a Message Channel
Access via the aura <lightning:messageChannel/> component
<lightning:messageChannel type="Record_Selected__c" onMessage="{!c.handleMessage}" />
LMS in Aura
lightning:messageChannel attributes
● onMessage
● scope
● type
One tag to rule them all
● Same tag for publishers and subscribers
● Subscription is implicit when handler
specified
● Message channel specified by literal
unqualified API name
In markup
<lightning:messageChannel
type="Record_Selected__c"
aura:id="recordSelected"
/>
In your controller
var payload = { recordId: event.target.contact.Id };
component.find('recordSelected').publish(payload);
In Aura
Publishing a Message
<lightning:messageChannel
type="Record_Selected__c"
aura:id="recordSelected"
onMessage="{!c.handleMessage}"
/>
...yep...that's literally all you do
In Aura
Subscribing to a Message Channel
Access via standard Visualforce objects
setPageConfigs({
messageChannel: '{!$MessageChannel.Record_Selected__c}',
lmsSubscribe: sforce.one.subscribe
});
LMS in Visualforce
sforce.one functions
● publish
● subscribe
● unsubscribe
Message Channel
● Surfaced as a global variable by API name
under $MessageChannel
● Bind and assign to a JS variable
Visualforce page
setPageConfigs({
messageChannel: '{!$MessageChannel.Record_Selected__c}',
lmsPublish: sforce.one.publish
});
Static resource JS module
const payload = { recordId: selectedIdNode.dataset.id };
_pageConfigs.lmsPublish(_pageConfigs.messageChannel, payload);
In Visualforce
Publishing a Message
Visualforce page
setPageConfigs({
messageChannel: '{!$MessageChannel.Record_Selected__c}',
lmsSubscribe: sforce.one.subscribe
});
Static resource JS module
document.addEventListener('readystatechange', (event) => {
if (event.target.readyState === 'complete') {
lmsChannelSubscription = _pageConfigs.lmsSubscribe(
_pageConfigs.messageChannel,
handleLMSMessageRemoting
);
}
});
In Visualforce
Subscribing to a Message Channel

More Related Content

PPTX
Building strong foundations apex enterprise patterns
PPTX
Apex code (Salesforce)
PPTX
Deep dive into Salesforce Connected App
PDF
Salesforce Field Service Lightning
PDF
Apex trigger framework Salesforce #ApexTrigger #Salesforce #SFDCPanther
PDF
Replicate Salesforce Data in Real Time with Change Data Capture
PDF
Apex Enterprise Patterns: Building Strong Foundations
PDF
Sales Lifecycle at Dreamforce 2014
Building strong foundations apex enterprise patterns
Apex code (Salesforce)
Deep dive into Salesforce Connected App
Salesforce Field Service Lightning
Apex trigger framework Salesforce #ApexTrigger #Salesforce #SFDCPanther
Replicate Salesforce Data in Real Time with Change Data Capture
Apex Enterprise Patterns: Building Strong Foundations
Sales Lifecycle at Dreamforce 2014

What's hot (20)

PPTX
Introduction to Apex for Developers
PPTX
Episode 10 - External Services in Salesforce
PPTX
SOQL & SOSL for Admins
PPTX
Modeling and Querying Data and Relationships in Salesforce
ODP
Relationships in Salesforce
PDF
A Comprehensive Guide to Salesforce Field Service
PDF
What Is Salesforce CRM, Editions, Licenses?
PDF
Lightning web components - Episode 1 - An Introduction
PDF
An Introduction to DocuSign for Salesforce
PDF
Secure Salesforce: External App Integrations
PDF
Securing Kafka
PPTX
Data Migration Made Easy
PPTX
Salesforce Overview For Beginners/Students
PPTX
Real Time Integration with Salesforce Platform Events
PDF
Introduction to the Salesforce Security Model
PDF
Introduction to External Objects and the OData Connector
PPTX
Large Data Volume Salesforce experiences
PDF
Salesforce Shield: How to Deliver a New Level of Trust and Security in the Cloud
PDF
Architecting Multi-Org Solutions
PDF
Deep dive into flink interval join
Introduction to Apex for Developers
Episode 10 - External Services in Salesforce
SOQL & SOSL for Admins
Modeling and Querying Data and Relationships in Salesforce
Relationships in Salesforce
A Comprehensive Guide to Salesforce Field Service
What Is Salesforce CRM, Editions, Licenses?
Lightning web components - Episode 1 - An Introduction
An Introduction to DocuSign for Salesforce
Secure Salesforce: External App Integrations
Securing Kafka
Data Migration Made Easy
Salesforce Overview For Beginners/Students
Real Time Integration with Salesforce Platform Events
Introduction to the Salesforce Security Model
Introduction to External Objects and the OData Connector
Large Data Volume Salesforce experiences
Salesforce Shield: How to Deliver a New Level of Trust and Security in the Cloud
Architecting Multi-Org Solutions
Deep dive into flink interval join
Ad

Similar to LMS Lightning Message Service (20)

PPTX
Kitchener Developer Group's session on "All about events"
PDF
WT19: Platform Events Are for Admins Too!
PDF
Winter '22 highlights
PDF
TrailheadX Presentation - 2020 Cluj
PDF
Stephen's 10 ish favourite spring'20 features
PDF
Alba Rivas - Building Slack Applications with Bolt.js.pdf
PPTX
Los Angeles Admin Trailblazer Community Group TrailheaDX 2020 Global Gatherin...
PDF
Dreamforce Global Gathering
PDF
Lightning Components 101: An Apex Developer's Guide
PDF
Salesforce Stamford developer group - power of flows
PPTX
Deep dive into salesforce connected app part 4
PDF
TDX Global Gathering - Wellington UG
PPTX
Stamford developer group Experience Cloud
PPTX
Summer 23 LWC Updates + Slack Apps.pptx
PDF
Delivering powerful integrations without code using out-of-the-box Salesforce...
PDF
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
PPTX
London Salesforce Developers TDX 20 Global Gathering
PDF
How to excel at your next Salesforce Hackathon (1).pdf
PPTX
Introduction to Salesforce Pub-Sub APIs/Architecture
PDF
Jaipur MuleSoft Meetup No. 3
Kitchener Developer Group's session on "All about events"
WT19: Platform Events Are for Admins Too!
Winter '22 highlights
TrailheadX Presentation - 2020 Cluj
Stephen's 10 ish favourite spring'20 features
Alba Rivas - Building Slack Applications with Bolt.js.pdf
Los Angeles Admin Trailblazer Community Group TrailheaDX 2020 Global Gatherin...
Dreamforce Global Gathering
Lightning Components 101: An Apex Developer's Guide
Salesforce Stamford developer group - power of flows
Deep dive into salesforce connected app part 4
TDX Global Gathering - Wellington UG
Stamford developer group Experience Cloud
Summer 23 LWC Updates + Slack Apps.pptx
Delivering powerful integrations without code using out-of-the-box Salesforce...
Spring 21 Salesforce Release Highlights with Awesome Admin Marc Baizman Welli...
London Salesforce Developers TDX 20 Global Gathering
How to excel at your next Salesforce Hackathon (1).pdf
Introduction to Salesforce Pub-Sub APIs/Architecture
Jaipur MuleSoft Meetup No. 3
Ad

More from Peter Chittum (20)

PPTX
Dreamforce 2013 - Enhancing the Chatter Feed with Topics and Apex
PDF
Winter 21 Developer Highlights for Salesforce
PPTX
Apply the Salesforce CLI To Everyday Problems
PDF
If You Can Write a Salesforce Formula, You Can Use the Command Line
PDF
If you can write a Salesforce Formula you can use the command line
PDF
Do Not Fear the Command Line
PPTX
Don't Fear the Command Line
PPTX
The Power of Salesforce APIs World Tour Edition
PPTX
Maths Week - About Computers, for Kids
PPTX
Best api features of 2016
PDF
Streaming api with generic and durable streaming
PDF
Spring '16 Release Overview - Bilbao Feb 2016
PDF
Salesforce Platform Encryption Developer Strategy
PDF
All Aboard the Lightning Components Action Service
PDF
Boxcars and Cabooses: When One More XHR Is Too Much
PDF
Dreamforce 15 - Platform Encryption for Developers
PPTX
Platform Encryption World Tour Admin Zone
PDF
Salesforce Lightning Components and App Builder EMEA World Tour 2015
PPTX
Building Applications on the Salesforce1 Platform for Imperial College London
PDF
Elevate london dec 2014.pptx
Dreamforce 2013 - Enhancing the Chatter Feed with Topics and Apex
Winter 21 Developer Highlights for Salesforce
Apply the Salesforce CLI To Everyday Problems
If You Can Write a Salesforce Formula, You Can Use the Command Line
If you can write a Salesforce Formula you can use the command line
Do Not Fear the Command Line
Don't Fear the Command Line
The Power of Salesforce APIs World Tour Edition
Maths Week - About Computers, for Kids
Best api features of 2016
Streaming api with generic and durable streaming
Spring '16 Release Overview - Bilbao Feb 2016
Salesforce Platform Encryption Developer Strategy
All Aboard the Lightning Components Action Service
Boxcars and Cabooses: When One More XHR Is Too Much
Dreamforce 15 - Platform Encryption for Developers
Platform Encryption World Tour Admin Zone
Salesforce Lightning Components and App Builder EMEA World Tour 2015
Building Applications on the Salesforce1 Platform for Imperial College London
Elevate london dec 2014.pptx

Recently uploaded (20)

PDF
AI in Product Development-omnex systems
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Nekopoi APK 2025 free lastest update
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
ai tools demonstartion for schools and inter college
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
L1 - Introduction to python Backend.pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
medical staffing services at VALiNTRY
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Digital Strategies for Manufacturing Companies
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
history of c programming in notes for students .pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
AI in Product Development-omnex systems
How to Choose the Right IT Partner for Your Business in Malaysia
Nekopoi APK 2025 free lastest update
CHAPTER 2 - PM Management and IT Context
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Design an Analysis of Algorithms I-SECS-1021-03
ai tools demonstartion for schools and inter college
Adobe Illustrator 28.6 Crack My Vision of Vector Design
L1 - Introduction to python Backend.pptx
Understanding Forklifts - TECH EHS Solution
medical staffing services at VALiNTRY
wealthsignaloriginal-com-DS-text-... (1).pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Digital Strategies for Manufacturing Companies
Which alternative to Crystal Reports is best for small or large businesses.pdf
history of c programming in notes for students .pptx
Odoo POS Development Services by CandidRoot Solutions

LMS Lightning Message Service

  • 1. Lightning Message Service @pchittum | pchittum@salesforce.com Peter Chittum, Sr Director Developer Evangelism
  • 2. Forward-Looking Statement Statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company’s financial and operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates, the one-time accounting non-cash charge that was incurred in connection with the Salesforce.org combination; stock- based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth and sustainability goals. The achievement or success of the matters covered by such forward-looking statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could differ materially from the results expressed or implied by the forward-looking statements we make. The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of geopolitical events; the impact of foreign currency exchange rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and prevent, detect and remediate potential security breaches; the expenses associated with new data centers and third-party infrastructure providers; additional data center capacity; real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market; our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly traded companies within the company's strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies, including delays related to the integration of Tableau due to regulatory review by the United Kingdom Competition and Markets Authority; our ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our outstanding debt, revolving credit facility, term loan and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving us; and the impact of climate change. Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s website at www.salesforce.com/investor. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.
  • 4. Principles of Message Service Client-side event bus between DOM branches LWC, Aura, and Visualforce as Equal Citizens Don't Be Surprising (Scope)
  • 7. LWC, Aura, Visualforce as Equal Citizens
  • 9. Context Distinguish between different near-root level DOM features
  • 10. Scope Whether a subscriber remains active when its context becomes inactive
  • 11. Resources Learn MOAR Summer 20 Release blog: https://bit.ly/lms-launch-blog Follow the work in this github issue: https://bit.ly/lms-recipe-issue Scoped Messaging example: https://bit.ly/lms-with-scope
  • 13. Appendix A: All The Samples Where can I go to find other resources to learn about LMS (apart from the docs, of course)
  • 14. Internal LMS Example Inventory LWC Recipes Sample App ● LWC Publisher ● LWC Subscriber ● Aura Publisher ● Aura Subscriber ● VF Publisher ○ Page and Static Resource ● VF Subscriber (with postback) ○ Page and Static Resource ● VF Subscriber (with remote obj) ○ Page and Static Resource E-Bikes Sample App ● productTileList ● productCard ● productFilter Dreamhouse Sample App ● propertySummary ● daysOnMarket ● propertyFilter ● propertyMap ● propertyTileList Easy Spaces Sample App ● reservationHelper ● reservationList ● customerList ● spaceDesigner Trailhead Modules and Projects ● Build a Bear-Tracking App with Lightning Web Components Project
  • 15. Appendix: the LMS APIs A summary of interacting with LMS across all three Salesforce UI technologies: LWC, Aura, Visualforce
  • 16. LMS Moving Parts The message service: the reusable parts, used to publish, subscribe, etc. The message channel: a way to name and segment messages (Note: for all examples we're using the recipes in the LWC Recipes sample app)
  • 17. The above message channel would be referenced as Record_Selected__c in code Message Channel Metadata Definining a Message Channel
  • 18. Import via ES6 modules import { subscribe, publish, MessageContext } from 'lightning/messageService'; import RECORD_SELECTED_CHANNEL from '@salesforce/messageChannel/Record_Selected__c'; LMS in LWC MessageService imports ● publish ● subscribe ● unsubscribe ● MessageContext ● APPLICATION_SCOPE Message Channel ● Surfaced as an ES6 module by API name in the @salesforce module scope ● Use default import syntax
  • 19. export default class LmsPublisherWebComponent extends LightningElement { @wire(getContactList) contacts; @wire(MessageContext) messageContext; // Respond to UI event by publishing message handleContactSelect(event) { const payload = { recordId: event.target.contact.Id }; publish(this.messageContext, RECORD_SELECTED_CHANNEL, payload); } } In LWC Publishing a Message
  • 20. export default class LmsSubscriberWebComponent extends LightningElement { subscription = null; ... @wire(MessageContext) messageContext; ... subscribeToMessageChannel() { this.subscription = subscribe( this.messageContext, RECORD_SELECTED_CHANNEL, (message) => this.handleMessage(message) ); } ... connectedCallback() { this.subscribeToMessageChannel(); } In LWC Subscribing to a Message Channel
  • 21. Access via the aura <lightning:messageChannel/> component <lightning:messageChannel type="Record_Selected__c" onMessage="{!c.handleMessage}" /> LMS in Aura lightning:messageChannel attributes ● onMessage ● scope ● type One tag to rule them all ● Same tag for publishers and subscribers ● Subscription is implicit when handler specified ● Message channel specified by literal unqualified API name
  • 22. In markup <lightning:messageChannel type="Record_Selected__c" aura:id="recordSelected" /> In your controller var payload = { recordId: event.target.contact.Id }; component.find('recordSelected').publish(payload); In Aura Publishing a Message
  • 24. Access via standard Visualforce objects setPageConfigs({ messageChannel: '{!$MessageChannel.Record_Selected__c}', lmsSubscribe: sforce.one.subscribe }); LMS in Visualforce sforce.one functions ● publish ● subscribe ● unsubscribe Message Channel ● Surfaced as a global variable by API name under $MessageChannel ● Bind and assign to a JS variable
  • 25. Visualforce page setPageConfigs({ messageChannel: '{!$MessageChannel.Record_Selected__c}', lmsPublish: sforce.one.publish }); Static resource JS module const payload = { recordId: selectedIdNode.dataset.id }; _pageConfigs.lmsPublish(_pageConfigs.messageChannel, payload); In Visualforce Publishing a Message
  • 26. Visualforce page setPageConfigs({ messageChannel: '{!$MessageChannel.Record_Selected__c}', lmsSubscribe: sforce.one.subscribe }); Static resource JS module document.addEventListener('readystatechange', (event) => { if (event.target.readyState === 'complete') { lmsChannelSubscription = _pageConfigs.lmsSubscribe( _pageConfigs.messageChannel, handleLMSMessageRemoting ); } }); In Visualforce Subscribing to a Message Channel