Created
March 29, 2019 15:31
-
-
Save iagodahlem/dea52f1502c9bc631a130929fd6c06ca to your computer and use it in GitHub Desktop.
Scalable Frontend - The State Layer - Ducks Pattern
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
export const AUTH = { | |
SIGN_IN_REQUEST: 'SIGN_IN_REQUEST', | |
SIGN_IN_SUCCESS: 'SIGN_IN_SUCCESS', | |
SIGN_IN_ERROR: 'SIGN_IN_ERROR', | |
} | |
export const ARTICLE = { | |
LOAD_ARTICLE_REQUEST: 'LOAD_ARTICLE_REQUEST', | |
LOAD_ARTICLE_SUCCESS: 'LOAD_ARTICLE_SUCCESS', | |
LOAD_ARTICLE_ERROR: 'LOAD_ARTICLE_ERROR', | |
} | |
export const EDITOR = { | |
UPDATE_FIELD: 'UPDATE_FIELD', | |
ADD_TAG: 'ADD_TAG', | |
REMOVE_TAG: 'REMOVE_TAG', | |
RESET: 'RESET', | |
} |
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
import { AUTH } from './actionTypes' | |
export const reducer = (state, action) => { | |
switch (action.type) { | |
// ... | |
case AUTH.SIGN_IN_SUCCESS: // <- same action for different reducers | |
return { | |
...state, | |
user: action.user, | |
} | |
// ... | |
} | |
} |
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
import { AUTH } from './actionTypes' | |
export const reducer = (state, action) => { | |
switch (action.type) { | |
// ... | |
case AUTH.SIGN_IN_SUCCESS: // <- same action for different reducers | |
case AUTH.SIGN_IN_ERROR: | |
return { | |
...state, | |
showSpinner: false, | |
} | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment