Skip to content

Commit

Permalink
Support for injecting models (#25)
Browse files Browse the repository at this point in the history
* Add support for injecting models

* Ignore coverage folder
  • Loading branch information
alexmiranda authored Aug 18, 2016
1 parent e2e1775 commit e8b482c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ lib
*.swp
*.swo


coverage
8 changes: 7 additions & 1 deletion src/components/mapToProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function mapToProps(opts = {}) {
...stateProps,
};
},
models: {},
options: {},
services: {},
shared: () => {},
Expand All @@ -29,6 +30,7 @@ export default function mapToProps(opts = {}) {
readableStores: {},
services: {},
factories: {},
models: {},
};
},

Expand Down Expand Up @@ -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);
})
});
},
Expand All @@ -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 {
Expand All @@ -82,6 +87,7 @@ export default function mapToProps(opts = {}) {
...mappedAppToProps,
...services,
...factories,
...models,
};
};

Expand Down

0 comments on commit e8b482c

Please sign in to comment.