Skip to content

Instantly share code, notes, and snippets.

@iamnasirudeen
Created June 24, 2020 21:28
Show Gist options
  • Save iamnasirudeen/efcba519c7e4421454da9cb700b08b9f to your computer and use it in GitHub Desktop.
Save iamnasirudeen/efcba519c7e4421454da9cb700b08b9f to your computer and use it in GitHub Desktop.
```
import Notification from "../../models/Notifications";
const eventNames = require("./eventNames");
const userManager = require("./userManager");
const notificationEvent = async (
io,
socket,
userId,
notification = { name: "test" }
) => {
const currentUserSocketId = await userManager.getUser(
"5ef14be14347471aaeb6ab7e"
);
io.to(currentUserSocketId).emit("welcome", notification);
};
module.exports = notificationEvent;
```
## How do i use this notificationEvent module in my controller, since we are passing the **io* and **socket** argument from another file (**socketEvents.js**)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment