Created
January 16, 2021 14:32
-
-
Save rafagsiqueira/97013ae5c8241fbb54229783e8d45a46 to your computer and use it in GitHub Desktop.
Sending emails in parallel with mergeMap
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
const users$ = getUsers$(); | |
users$.pipe( | |
filter(user => user.isActive), | |
mergeMap(user => 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