Created
May 14, 2018 23:17
-
-
Save toruticas/96862b328c0f317c1b19a08536b979be to your computer and use it in GitHub Desktop.
Redux simple explanation
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
store.dispatch({ | |
type: 'OPEN_NFE_VISUALIZATION', | |
accessKey: 123 | |
}) | |
store.dispatch({ | |
type: 'CLOSE_NFE_VISUALIZATION' | |
}) |
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
function nfeList(state = {}, action) { | |
switch (action.type) { | |
case 'OPEN_NFE_VISUALIZATION': | |
return { | |
...state, | |
nfeIsOpen: true, | |
nfeTargetAK: action.accessKey | |
} | |
case 'CLOSE_NFE_VISUALIZATION': | |
return { | |
...state, | |
nfeIsOpen: true, | |
nfeTargetAK: -1, | |
} | |
default: | |
return state | |
} | |
} |
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
console.log(store.getState()) | |
/* Console Output | |
{ | |
data: [{ | |
accessKey: 123, | |
cnpj: "00.000.000/0000-00", | |
value: 100.00 | |
}, { | |
accessKey: 124, | |
cnpj: "00.000.000/0001-00", | |
value: 200.00 | |
}], | |
nfeIsOpen: false, | |
nfeTargetAK: -1, | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment