Created
June 24, 2020 21:28
-
-
Save iamnasirudeen/efcba519c7e4421454da9cb700b08b9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
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