Skip to content

Instantly share code, notes, and snippets.

@rafagsiqueira
Created January 16, 2021 14:32
Show Gist options
  • Save rafagsiqueira/97013ae5c8241fbb54229783e8d45a46 to your computer and use it in GitHub Desktop.
Save rafagsiqueira/97013ae5c8241fbb54229783e8d45a46 to your computer and use it in GitHub Desktop.
Sending emails in parallel with mergeMap
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