Last active
December 16, 2015 19:35
-
-
Save alexbeletsky/20fb36c669c567fbb588 to your computer and use it in GitHub Desktop.
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
// 1. some-component.js | |
dispatch(makeSomeMagic({ focus: 'pokus' })); | |
// 2. action-creators.js | |
export makeSomeMagic = (data) => { | |
return { type: constants.MAKE_SOME_MAGIC, payload: data }; | |
} | |
// 3. constans.js | |
const export MAKE_SOME_MAGIC = 'MAKE_SOME_MAGIC'; | |
// 4. reducers.js | |
const reducers = { | |
[constants.MAKE_SOME_MAGIC]: (state, action) => { | |
// finally do some magic here... | |
}; | |
} | |
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
// 1. some-component.js | |
dispatch(makeSomeMagic({ focus: 'pokus' })); | |
// 2. some-handler.j | |
const SomeMagicHander = (reducerFactory) => { | |
const MAKE_SOME_MAGIC = 'MAKE_SOME_MAGIC'; | |
const reducer = (state, action) => { | |
// finally do some magic here... | |
}; | |
const action = (data) => { | |
return { type: MAKE_SOME_MAGIC, payload: data }; | |
} | |
return { | |
id: MAKE_SOME_MAGIC, | |
reducer, | |
action | |
}; | |
} | |
export SomeMagicHandler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment