There are a lot of different ways to communicate between different types of lightning components (lwc to lwc, lwc to aura, aura to lwc etc). In this blog we will cover all different ways of communicating between different types of lwc and aura components.
Communication patterns between Lightning components
-
LWC parent component to LWC child component
From a parent component to child component you can just pass data through
attributes
without any events. sample code -
LWC child component to LWC parent component
A
CustomEvent
needs to be fired from child lwc component and a listner needs to be added in parent component to send data from a child lwc component to it's parent lwc component sample code -
Between stand alone/independent LWC components - pubsub
pubsub
library provided by Salesforce is one approach to do this. sample code -
Between independent LWC component and Aura component - aurapubsub
aurapubsub
library provided by Salesforce is one approach to do this. sample code - LWC child component to aura parent component [COMING SOON]
- Aura parent component to LWC child component [COMING SOON]
- Aura stand alone component to LWC stand alone component [COMING SOON]
- Lighting message service
Interactions with Visualforce Page
Still some features like PDF rendering are only supported in Visualforce. There is a chance you might need to interact between lightning components and visualforce components. Some examples are listed below,
- Embedding visualforce page inside aura [COMING SOON]
- Embedding aura app inside visualforce [COMING SOON]
- Embedding visualforce page inside lwc [COMING SOON]
- Embedding lwc inside visualforce page [COMING SOON]
No comments:
Post a Comment