Skip to content

Instantly share code, notes, and snippets.

@pchab
Created June 30, 2021 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pchab/570a4ba4bc78470284827d4b85d72258 to your computer and use it in GitHub Desktop.
Save pchab/570a4ba4bc78470284827d4b85d72258 to your computer and use it in GitHub Desktop.
validation code saga with throttling
const VALIDATION_CODE_THROTTLE_TIME_IN_MS = 5000;
@Injectable()
export class ValidationCodeSagas {
@Saga()
ValidationCodeRequested = (event$: Observable<IEvent>): Observable<SendValidationCodeCommand> => {
return event$.pipe(
ofType(ValidationCodeGeneratedEvent),
throttleTime(VALIDATION_CODE_THROTTLE_TIME_IN_MS),
map(({ payload }) => new SendValidationCodeCommand(payload)),
);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment