Hello Friends, as you know that writing the reusable code good into Development /implementation .
Create Shared Code
To share code between components, create an ES6 module and use the standard export statement to export the functionality that your module exposes. Your module can use the standard import statement to use other shared modules
utils LWC Component
export default shpwToast (variant='info', mode='dismissable', title, message) {const event = new ShowToastEvent({ title: title, message: message, mode : mode, variant : variant }); return event; }
Note :- with in this component no html will be there.
Use Shared Code
To use the shared code in a JavaScript file, use the standard import statement. For example:
import {
shpwToast
} from 'c/utils';
This line imports the utils module in the c namespace.