Created
July 31, 2018 12:33
-
-
Save kievsash/790ac225cde676c8a553631ce0b193d4 to your computer and use it in GitHub Desktop.
distinctUntillChanges delay notification for same user but not for others
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 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