From e8b482c15c568df9c6c1412a3ced78df8646e627 Mon Sep 17 00:00:00 2001 From: Alex Miranda Date: Thu, 18 Aug 2016 16:24:03 +0200 Subject: [PATCH] Support for injecting models (#25) * Add support for injecting models * Ignore coverage folder --- .gitignore | 2 +- src/components/mapToProps.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 23421915..0cdc5725 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ lib *.swp *.swo - +coverage diff --git a/src/components/mapToProps.js b/src/components/mapToProps.js index 758f39b5..c6ac4145 100644 --- a/src/components/mapToProps.js +++ b/src/components/mapToProps.js @@ -14,6 +14,7 @@ export default function mapToProps(opts = {}) { ...stateProps, }; }, + models: {}, options: {}, services: {}, shared: () => {}, @@ -29,6 +30,7 @@ export default function mapToProps(opts = {}) { readableStores: {}, services: {}, factories: {}, + models: {}, }; }, @@ -61,6 +63,9 @@ export default function mapToProps(opts = {}) { }), factories: _.mapValues(options.factories, (factoryName) => { return this.context.app.getFactory(factoryName); + }), + models: _.mapValues(options.models, (modelName) => { + return this.context.app.getModel(modelName); }) }); }, @@ -73,7 +78,7 @@ export default function mapToProps(opts = {}) { }, render() { - const { mappedAppToProps, services, factories } = this.state; + const { mappedAppToProps, services, factories, models } = this.state; const combinedMapStateToProps = (...args) => { return { @@ -82,6 +87,7 @@ export default function mapToProps(opts = {}) { ...mappedAppToProps, ...services, ...factories, + ...models, }; };