A compiler and an interpreter are both useful tools for translating code, but there are some advantages to using a compiler over an interpreter in certain situations:
A compiler usually produces faster running code than an interpreter because it translates the entire program into machine code before execution.
Compiled code can be optimized for the specific computer architecture, it will run on, which can lead to more efficient use of system resources like memory and CPU.
Once a program is compiled, it can be run on any computer that has the necessary system libraries installed.
Compilers can often catch errors in code before the program is executed, which can save time in the debugging process.
Overall, compilers are generally better suited for larger programs or projects where performance and efficiency are important.
Lightning Message Service (LMS) in LWCSalesforce. LMS doesn’t need any relationship between the component. Just publish the event from one component and subscribe by multiple components simultaneously.
lightning-message-service-(lms)-in-lwc-output
Key Highlights :
Lightning Message Service is based on a new type of metadata: Lightning Message Channels
Enable communication between the Visualforce page, Lightning web components, and Aura components.
In LWC we will be using LMS when we want to send data from one LWC to another LWC which are not in the hierarchy.
Process & Code :
Step 1: Here we will create a Lightning Message Service (LMS) file in the messageChannels folder in the default branch.
<description>This is a Lightning Message Service Channel.</description>
<isExposed>true</isExposed>
<lightningMessageFields>
<description>This is sample message</description>
<fieldName>message</fieldName>
</lightningMessageFields>
<masterLabel>TechdicerChannel</masterLabel>
</LightningMessageChannel>
Step 2: In this step, we will create two LWC component which is not related to each other, one is the Publisher and another one is the Subscriber component.
lWCLMS.HTML: this is the Publisher component.
1
2
3
4
5
6
7
8
9
10
11
<template>
<lightning-cardtitle="Lightning Message Service (LMS) in LWC Publisher"icon-name="standard:contact">