Notes Used to Craft this Lesson
If you'll recall, our welcome email is being sent via an event listener.
// app/services/user_service.ts
export default class UserService {
/**
* Sends a welcome email to the user.
* The email is sent asynchronously and will not block the execution of the current code.
* @param data - An object containing the user's full name and email address
* @returns A promise resolving when the email is sent
*/
async sendWelcomeEmail(data: { fullName: string | null; email: string }) {
++ await emitter.emit('mail:send_welcome_email', data)
}
}