Comments (11)
I'm wondering in a situation where you've got a mongoose model, Blog
, that has Posts
. Post
, has a Blog
.
How can I avoid that (right now, it's just including each model via normal require — which works but misses the point of DI and better testing)?
I'd love to have electrolyte support that.
from electrolyte.
I'm also running into this problem with SequelizeJS when doing a relationship with A.hasMany(B) and B.belongsTo(A).
Edit: I was able to get around this for Sequelize by defining my models in separate files (which I was doing anyways), and then injecting them into a third class which creates the relationships. Not as clean as I'd like, but it will do for now.
from electrolyte.
I'm planning on adding a check for circular dependencies and throwing an error before the stack size is exceeded.
I don't know of a good workaround to the circular dependency problem. As a general rule, that's a sign that the two components need to be broken down (say add C that both A and B depend on, but C itself doesn't depend on either). If that's not possible, could you describe the relation of the components a bit more so I can understand it better and think on it?
from electrolyte.
https://github.com/jriecken/dependency-graph
from electrolyte.
@BrunoBernardino I had the same issue with Bookshelf. I ended up defining each model in their own file using electrolyte, and then having a 3rd file to attach the associations, sort of the A/B and C pattern @jaredhanson mentioned above.
It's not ideal, but it works and the 3rd file ends up being the entry point for all my models.
from electrolyte.
@jaredhanson any updates on this issue? It's kind of critical in my opinion that this gets fixed.
from electrolyte.
+1
from electrolyte.
👍
from electrolyte.
+1
from electrolyte.
👍
from electrolyte.
Still an issue in latest version 0.5
from electrolyte.
Related Issues (20)
- Implicit factory resolution HOT 2
- change default as singleton = true HOT 1
- change default as singleton = true HOT 3
- Better error handling on requiring component HOT 2
- Babel transpile with babel-preset-es2015 + async function breaks Electrolyte
- Electrolyte 0.4.0 should reject promise if a dependency is not found HOT 1
- Feature: Override existing Modules
- Release 0.4.0 - IoC.create now returns promise, createAsync doesn't exist HOT 4
- Failure to uphold semver expectations HOT 3
- version 0.3.0 returns objects while 0.4.0 returns promises HOT 11
- Child container
- support for es6 module syntax HOT 5
- Run example in repository : .get() requires callback functions but got a [object Object] Error: .get() requires callback functions but got a [object Object] HOT 5
- Unable to create object "XXXX" required by: unknown HOT 1
- Using it with class HOT 2
- Webpack? HOT 1
- Fix insecure dependencies
- Does IoC.use have to return a function? HOT 1
- Using custom resolvers to substitute components for testing and other purposes
- Is this repo being actively maintained HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electrolyte.