Skip to content

Instantly share code, notes, and snippets.

@uptownhr
Created June 24, 2016 23:12
Show Gist options
  • Save uptownhr/591ef8212c9e5a6270488911343361d0 to your computer and use it in GitHub Desktop.
Save uptownhr/591ef8212c9e5a6270488911343361d0 to your computer and use it in GitHub Desktop.
Decorator function example
/**
* 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