How to trigger emit or On function from different Js file?

Hello Developers, Good day, I’ve searched a lot of tutorials where I found everybody triggering socket,io emit and on function from main script like (app.js/main.js/index.js) where everything configured. But I need to how can I trigger these 2 items from different file. Like I have a controller I need to trigger On function how can I do that ?