redux-form-saga
redux-form-saga copied to clipboard
Create a setTypes func to override default status
The setTypes
function allows the user to override the default status.
For instance in my case, I don't use "FAILURE" but "ERROR".
With this PR, I could do the following:
import { setTypes, createFormAction } from 'redux-form-saga';
setTypes(["REQUEST", "SUCCESS", "ERROR"]);
const login = createFormAction("account/LOGIN");
Currently my two options are:
-
Fork this repo
-
Do the following:
export const LOGIN = "account/LOGIN"
function loginAction({ email, password }) {
return { type: LOGIN, payload: { email, password } }
}
export const LOGIN_SUCCESS = "account/LOGIN_SUCCESS"
export const LOGIN_ERROR = "account/LOGIN_ERROR"
const login = createFormAction(loginAction, [LOGIN_SUCCESS, LOGIN_ERROR])
And I have to define my own loginSuccess
and loginError
because the library doesn't generate them automatically anymore
export function loginSuccess(access_token, user) {
return { type: LOGIN_SUCCESS, payload: { access_token, user } }
}
export function loginError(error) {
return { type: LOGIN_ERROR, error: true, payload: error }
}
which make this library really less attractive for me..