Last active
April 1, 2020 18:51
-
-
Save stenin-nikita/2d34d1ba8518dce73bca04d7be71197e 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
const EFFECT = Symbol('@@Reatom/EFFECT'); | |
function createActionCreatorWithEffect(type, effect) { | |
return (payload) => ({ | |
type, | |
payload, | |
[EFFECT]: (store) => effect(payload, store), | |
}) | |
} | |
store.subscribe(action => { | |
if (typeof action[EFFECT] === 'function') { | |
action[EFFECT](store); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment