ForceChallenges
ProblemsDailyNotesInterview
Sign in

Practice

All problemsSOQL practiceApex trigger challengesDaily challengeOpportunityTrigger.oldMapBefore UpdateBulkificationContactValidationGROUP BYSemi-JoinAccountBefore Insert

Interview questions

All questionsAdminAdministrationApexApex TriggerAsync ApexDevelopmentField ServiceField ServiceIntegrationLwc

By company

DeloitteSalesforceAccentureInfosysPwCCognizant

Learn

Study notes

ForceChallenges

AboutContact usPrivacy PolicyTerms of ServiceFor AI assistants (llms.txt)
© 2026 ForceChallenges · Salesforce SOQL & Apex trigger practice
Development questions13 of 102
DevelopmentMedium 1 min read

What is Lightning Message Service (LMS) and how do you use it to communicate between components?

Answer

LMS lets components on the same Lightning page communicate regardless of DOM hierarchy, and works across LWC, Aura and Visualforce.

Steps:

  1. Create a Lightning Message Channel metadata file (MyChannel.messageChannel-meta.xml) defining fields.
  2. Publisher imports the channel and publish:
javascript
import { publish, MessageContext } from 'lightning/messageService';
import CHANNEL from '@salesforce/messageChannel/MyChannel__c';
@wire(MessageContext) messageContext;
publish(this.messageContext, CHANNEL, { recordId: this.id });
  1. Subscriber uses subscribe in connectedCallback and unsubscribe in disconnectedCallback.

It replaces the old pub-sub pattern and is the supported way to talk between unrelated components.

lwclmsmessaging
Practice SOQL & Apex
PreviousWhat is the difference between calling Apex with @wire and calling it imperatively in LWC?Next Write a SOQL query to retrieve Accounts ordered by Name in ascending order, locked for editing in Apex (FOR UPDATE), while enforcing User Mode permissions (WITH USER_MODE).

More Development questions

  • What is reactivity in LWC and when does a field trigger a re-render?
  • What are the best practices to improve LWC performance?
  • How do you unit test an LWC with Jest?
  • How do you use a third-party JavaScript library or static resource in LWC?
  • Why can renderedCallback run multiple times and how do you prevent repeated execution?