Created
December 7, 2018 14:32
-
-
Save vsavkin/f0e762e3396f34cf020ea72b4c47aefc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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