Rules
- no side effects (function can't rely on anything not provided to it)
- inputs and outputs
In Practice
- Nested functions are always an indication of complexity
Creates Functions that are
- Easy to read
- Easy to reuse
export function login(loginHandle, password) { | |
return { | |
types: [LOGIN_REQUEST, LOGIN_SUCCESS, LOGIN_FAILURE], | |
promise: (api) => api.post('/auth/login', { login: loginHandle, password }).then(response => { | |
setAuthCookie(response.token); // side effect pre success dispatch | |
return response; | |
}), | |
then: (response) => { | |
postLoginRedirect(browserHistory.push, response.user, response.organisation); // side effect post success dispatch | |
}, |
Rules
In Practice
Creates Functions that are