Created
February 5, 2016 08:46
-
-
Save christianalfoni/c9e91bad53a06948a2d3 to your computer and use it in GitHub Desktop.
FAQ: Why Cerebral does not provide context
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
/* | |
IT WAS SO NICE TO USE THE MODULE ARG | |
*/ | |
// With context | |
function action ({module}) { | |
module.state.set('foo', 'bar'); | |
} | |
// Now | |
function action ({state}) { | |
state.set('someModule.foo', 'bar'); | |
} | |
// 1. Same number of chars (Though that is not a factor) | |
// 2. It is explicit in the action which module you are changing the state of | |
/* | |
NOW I HAVE TO HARDCODE WHICH MODULE I AM GOING TO USE | |
*/ | |
// With context (moduleA.signals.signal) | |
[ | |
changeSomeSate // changes moduleA | |
] | |
// With context (moduleB.signals.signal) | |
[ | |
changeSomeState // change moduleB | |
] | |
// Now (moduleA.signals.signal) | |
[ | |
changeSomeSate('moduleA') // changes moduleA | |
] | |
// Now (moduleB.signals.signal) | |
[ | |
changeSomeState('moduleB') // change moduleB | |
] | |
// Now also (moduleA.signals.signal) | |
[ | |
changeModuleAState // change moduleA | |
] | |
// Now also (moduleB.signals.signal) | |
[ | |
changeModuleAState // change moduleA | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment