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
// When SUBMIT action happens: | |
// - emit VALIDATE action, | |
// - validate the form, | |
// - and when validating the form finishes with success: | |
// - emit SUBMIT_START action. | |
const validateOnSubmitEpic = (action$, state$) => { | |
return action$.ofType(SUBMIT).switchMap(() => { | |
const validate$ = Observable.of({ type: VALIDATE }); | |
const onValidate$ = Observable.merge( | |
action$.ofType({ type: VALIDATE_SUCCESS }), | |
action$.ofType({ type: VALIDATE_FAILURE }) | |
) | |
.first() | |
.filter(action => action.type === VALIDATE_SUCCESS) | |
.mapTo({ type: SUBMIT_START }); | |
return Observable.merge(validate$, onValidate$); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment