Last active
August 29, 2015 14:27
-
-
Save rt2zz/5d4c0cea90b5b9155fb6 to your computer and use it in GitHub Desktop.
Side Effects API's
This file contains hidden or 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
// side effects are created by reducer, but executed by store | |
function reducer(state, action, createSideEffect){ | |
if(action.type === 'SUBMIT_DATA'){ | |
createSideEffect(({action, getState, dispatch}) => { | |
//.. do work | |
}) | |
} | |
} |
This file contains hidden or 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
// similar to above, but instead of creating side effects in the reducer, they are created and executed in a remote which the store invokes | |
function remote(action, finish, dispatch){ | |
if(action.type === 'SUBMIT_DATA'){ | |
//.. do work | |
} | |
} |
This file contains hidden or 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
// basically redux-thunk with labels and better logging | |
dispatch.signal('submitData', (state, dispatch) => { | |
//.. do work | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Questions:
#1. Where are side effects written?
#2. Are side effects one to one with actions or one to many
#3. Who executes side effects?