3

i am trying to make communicate component with each other which are independent(nonrelated), when i am trying to push source to org it showing error 'No MODULE named markup://c:pubsub found : [markup://c:meetingRoom]'. Please help me with it. Thank you. here is my code:

selectedMeetingRoom.html

<template>
    <lightning-card title="Meeting Room">
        You Have Selected : {selectedMeetingRoom.roomName}
        You Have Selected : {selectedMeetingRoom.roomCapacity}
    </lightning-card>
</template>

selectedMeetingRoom.js

import { LightningElement, wire } from 'lwc';
import {registerListener, unregisterAllListeners} from 'c/pubsub' ;
import {CurrentPageReference} from 'lightning/navigation';


export default class SelectedMeetingRoom extends LightningElement {
    selectedMeetingRoom;

    @wire(CurrentPageReference) pageRef;

    connectedCallback(){
        registerListener('pubsubtileclick', this.onMeetingRoomSelectHabdler, this);
    }

    disconnectedCallback(){
        unregisterAllListeners(this);
    }

    onMeetingRoomSelectHabdler(payload){
        this.selectedMeetingRoom = payload;
    }
}

meetingRoom.html

<template>
    <lightning-card title="Meeting Rooms">
        <lightning-layout>
            <lightning-layout-item size="4" padding="around-small">
                <ul>
                    <template for:each={meetingRoomsInfo} for:item="room">
                    <li key={room.roomName} style="padding: 10px">
                        <c-meeting-room meeting-room-info={room} show-room-info ></c-meeting-room>

                    </li>
                    </template>
                </ul>
            </lightning-layout-item>
            <lightning-layout-item>
                You Have Selected : {selectedMeetingRoom}
            </lightning-layout-item>
        </lightning-layout>

</lightning-card>
</template>

meetingRoom.js

import {LightningElement, wire, api} from 'lwc';

import {CurrentPageReference} from 'lightning/navigation';

import {fireEvent} from 'c/pubsub';

export default class MeetingRoom extends LightningElement {
    @api meetingRoomInfo;

    @api showRoomInfo = false;

    @wire(CurrentPageReference) pageReference;

    tileClickHandler(){
        const tileClicked = new CustomEvent('tileclick', {detail : this.meetingRoomInfo, bubbles:true});

        this.dispatchEvent(tileClicked);
        fireEvent(this.pageReference, 'pubsubtileclick', this.meetingRoomInfo);
    }
} 

meta files are set to true for isExposed in both.

0

1 Answer 1

4

The pubsub module is not a standard module provided by Salesforce. The LWC developer docs states to copy the module from the lwc-recipes repo:

IMPORTANT The Lightning web components sample repositories include a pubsub module. Copy the pubsub module and use it in your code.

You will need to create the component in your org.

3
  • Yeah it worked. thank you so much.
    – sameer
    Commented Jun 5, 2020 at 13:57
  • I'm still getting the error "No MODULE named markup://devopsimpkg11:pubsub found : [markup://c:createAccount]" after deploying pubsub from your link
    – compski
    Commented May 30, 2023 at 7:11
  • My answer was from 2020 when you needed to bring in that component from a repo to use messaging. Use the Lightning Message Service now - refer to the repo README.
    – nbrown
    Commented Jun 1, 2023 at 0:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .