vojtajina/node-di — pull request #8 by caitp (2013-12-08 03:39:39+00:00)
Title: Resolve module dependencies (as promises) before invoking

Similar to ngRoute's `resolve` property in route configuration, it should be possible to support asynchronous module dependencies in this fashion.

I opened https://github.com/karma-runner/karma/issues/851 on karma a while ago, but it seems like the simplest solution would be adjusting the DI mechanics.

I'll work on a patch for this, but it would be good to hear thoughts about it.

... hmmm I guess it's not easy to do this without changing the API :(

Would it be okay for `invoke()` to return a promise, so that it could wait for promises to be resolved? (realizing fully well that this would be a pretty breaking change)

...

Alternatively, a similar approach to grunt --- call a module with a context containing a method like `async()` which would return a means to notify the caller that it was finished... and just block until everything is finished... although that might not necessarily work either. hmmm :(