Skip to content

Instantly share code, notes, and snippets.

@kievsash
Created July 31, 2018 12:33
Show Gist options
  • Save kievsash/790ac225cde676c8a553631ce0b193d4 to your computer and use it in GitHub Desktop.
Save kievsash/790ac225cde676c8a553631ce0b193d4 to your computer and use it in GitHub Desktop.
distinctUntillChanges delay notification for same user but not for others
let usersToDelay = {}
action$
.ofType(OPEN_NOTIFICATION)
.distinctUntilChanged( (prev, next) => {
let userName = next.userName;
if (usersToDelay[userName]) {
return true; // do not emit notification
}
setTimeout(() => {delete usersToDelay[userName];}, 3000);
return false; //emit if another use;
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment