Created
June 30, 2021 17:06
-
-
Save pchab/570a4ba4bc78470284827d4b85d72258 to your computer and use it in GitHub Desktop.
validation code saga with throttling
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 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