tschneidereit / SwiftSuspenders

NOTE: Find the offical repo at http://github.com/robotlegs/swiftsuspenders
https://github.com/robotlegs/swiftsuspenders
MIT License
280 stars 89 forks source link

Implement live injections #44

Closed tschneidereit closed 12 years ago

tschneidereit commented 13 years ago

Marking an injection point as "live" should cause it to be updated as soon as the mapped value changes.

tschneidereit commented 12 years ago

Turns out I'll probably not implement this feature after all. If anyone absolutely wants to implement it and sends a pull request with good implementation and tests, I'll probably merge that, but I'm mostly of the opinion that a real binding solution should be used here, instead.

darl2ng commented 11 years ago

Hi,

Just for the record, I don't think a general circular case such as A needs B, B needs C and C needs A should fit with a binding solution. Indeed, binding to me would be the case where A needs B and B needs A, thus both direction.

Thanks for your great work,

darl2ng commented 11 years ago

I'd like to add that a setter injection that supports circular injection as in Spring could be interesting :-)

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#d0e2299

tschneidereit commented 11 years ago

I'd like to add that a setter injection that supports circular injection as in Spring could be interesting :-)

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#d0e2299

While I agree that having support for circular dependencies would be handy, supporting it would require a major rewrite of core parts of Swiftsuspenders. I'm very unlikely to do this rewrite, so I'm afraid this isn't going to happen, sorry.

MindScriptAct commented 11 years ago

Hi,

circular dependencies are supported in mvcExpress. Currently it is on the branch : release_1.0

https://github.com/MindScriptAct/mvcExpress-framework/commit/9e15e2e3e5c4c3b51f3c755a5de99d4eb8584668

My approach is simple - if dependency is not satisfied AND pending injection feature is enabled - injection goes to pending dependencies registry. If dependency is set in fixed(can be changed) time frame... all is well.. if not - error is thrown.

By default I disable the feature because some nasty synchronization problem might occur if programmer does not know what he is doing...

Maybe it will help.

cheers.