Created
June 21, 2019 20:29
-
-
Save JitendraZaa/8f31763afbcd129d37475b4a089156e0 to your computer and use it in GitHub Desktop.
Honda Lightning Web Component to handle pub sub event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| This is Honda Component <br /> | |
| {data} | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { LightningElement, track,api } from 'lwc'; | |
| import pubsub from 'c/pubsub' ; | |
| export default class Honda extends LightningElement { | |
| @track data; | |
| eventFiredCallback; | |
| eventFired(event){ | |
| this.data=event ; | |
| } | |
| connectedCallback(){ | |
| this.data='callback' ; | |
| this.eventFiredCallback = this.eventFired.bind(this); | |
| this.register(); | |
| } | |
| @api | |
| register(){ | |
| this.data+=' - register' ; | |
| pubsub.register('uniqueEventId', this.eventFiredCallback ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment