4

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

1 Answer 1

6

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';

You must log in to answer this question.

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