PubSub pattern in LWC

 PubSub design pattern:- 

  Pubsub is a singleon library(Java Script file) that follows publish subscribe pattern.

 If componets  which are not situated in the same DOM  tree wants to communicate                 between   themselves, we have  to  use  publish subscriber  model in Lightning Web     Component.

  Pub-sub is like Application Event in Lightning Aura Component.

 In a  publish-subscribe pattern one component  publishes an event while the other components  subscribe to receive and handle  the event.

Every component that subscribe  to the event  receive the event.

NOTE.  Publish-Subscribe  Model only works for components that are on the same page

Comments

Popular posts from this blog

Security model

EVENTS IN Lightning Web Components

Lightning web Components.