Skip to content

Instantly share code, notes, and snippets.

@vsavkin
Created December 7, 2018 14:32
Show Gist options
  • Save vsavkin/f0e762e3396f34cf020ea72b4c47aefc to your computer and use it in GitHub Desktop.
Save vsavkin/f0e762e3396f34cf020ea72b4c47aefc to your computer and use it in GitHub Desktop.
function FromStore(config: {[k: string]: string}) {
return (clazz: any) => {
const originalFactory = clazz.ngComponentDef.factory;
clazz.ngComponentDef.factory = () => {
const cmp = originalFactory(clazz.ngComponentDef.type);
const store = directiveInject(Store);
Object.keys(config).forEach((key: string) => {
cmp[key] = store.pipe(select(config[key]));
});
return cmp;
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment