1

Below is my publisher. It's nested in an Aura component, which is itself on a community page:

import {LightningElement, wire, track, api} from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import { fireEvent } from 'c/pubsub';

export default class AppFeeProcInfoPub extends LightningElement {
    @wire(CurrentPageReference) pageRef;

    @api basePaymentInfo;

    @api
    get showCCForm() {}

    set showCCForm(value) {     
        if(value){ 
            let payload = Object.assign({}, this.basePaymentInfo);
            payload.renderComp = value;
            console.log('payload.renderComp: '+payload.renderComp);
            console.log('payload: '+JSON.stringify(payload));
            fireEvent(this.pageRef, "publisherLoaded", payload);
            console.log('paymentProcessorInfoPublisher publishing');            
        }
    }
}

When the page loads and the condition is met, it fires the pub event.

Below is my subscriber:

//LWC Framework
import { LightningElement, wire, track, api } from 'lwc';
import { registerListener, unregisterAllListeners } from 'c/pubsub';
import { CurrentPageReference } from 'lightning/navigation';
//Apex methods
import processPaymentTransaction from '@salesforce/apex/Aura_MedicalSchoolApplication.processPaymentTransaction';

export default class PaymentProcessor extends LightningElement {
    paymentInfo;

    @api renderComp;

    @wire(CurrentPageReference) pageRef;

    connectedCallback() {
        registerListener("publisherLoaded", this.handlePublisherLoaded, this);
    }

    disconnectedCallback() {
        unregisterAllListeners(this);
    }

    handlePublisherLoaded(payload) {
        console.log('paymentProcessor recieving');
        console.log('payload.renderComp: '+payload.renderComp);
        if(payload.renderComp){ 
            this.renderComp = payload.renderComp;
            delete payload.renderComp
        }

        this.paymentInfo = payload;         
    }
}

When I preview the community page as an admin from the community builder, handlePublisherLoaded executes.

Here are the logs:

enter image description here

But logging in as a regular community user, handlePublisherLoaded does not execute. Here are the logs:

enter image description here

Why could this be?

UPDATE:

Apparently the LWC's problem has nothing to do with it being a subscriber. I commented out all it's functions, left only its properties. It renders in builder preview but not when logged in as a community user. It's as if it is failing to load at all.

1 Answer 1

0

I just needed to publish my changes in the community.

You must log in to answer this question.

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