Last active
January 16, 2021 14:20
-
-
Save rafagsiqueira/d5bbda3c74ec9a906bf15c51208f3668 to your computer and use it in GitHub Desktop.
Example of sending emails using a stream of users
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
let users$ = from(getUsers()); | |
users$.pipe( | |
filter(user => user.isActive), | |
concatMap(user => from(sendEmail(user.email))) | |
).subscribe( | |
(success) => emailsSent++, | |
(err) => failedEmails++, | |
() = > console.log('Emails sent:'+emailsSent+' Emails failed:'+failedEmails) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment