3

As both empApi and LMS require the import of the subscribe and unsubscribe methods. How can you use both within the same component?

import { subscribe, unsubscribe} from 'lightning/empApi';
import { subscribe, unsubscribe} from 'lightning/messageService';

This returns the following error:

Identifier 'subscribe' has already been declared 

This seems like a big oversight in the LMS development.

Is the only way around this to use a child component that just listens for the LMS then bubbles the details back up?

Thanks

3

One of the approach could be to use aliases in order distinguish between different modules as described here

For example:

import { subscribe as empSubscribe, unsubscribe as empUnsubscribe} from 'lightning/empApi';
import { subscribe , unsubscribe} from 'lightning/messageService';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.