Created
June 24, 2016 23:12
-
-
Save uptownhr/591ef8212c9e5a6270488911343361d0 to your computer and use it in GitHub Desktop.
Decorator function example
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
/** | |
* Observer function / decorator | |
*/ | |
function observer(arg1, arg2) { | |
if (typeof arg1 === "string") | |
throw new Error("Store names should be provided as array"); | |
if (Array.isArray(arg1)) { | |
// component needs stores | |
if (!arg2) { | |
// invoked as decorator | |
return function(componentClass) { | |
return observer(arg1, componentClass); | |
} | |
} else { | |
return createStoreInjector(arg1, observer(arg2)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment