4 ms·
Require.JS is a service locator. It's not an inversion of control dependency injector. You can swap in a different service locator for your tests, but it's mess
by lern_too_spel 13y ago
Require.JS is a service locator. It's not an inversion of control dependency injector. You can swap in a different service locator for your tests, but it's messier than just directly passing in different dependencies for your tests.
- anton-107 13y agoWell yes, Require.JS is not strictly speaking a dependency injector (however you can use it as one), but underlying AMD pattern is a very good example of IoC. And this allows all kinds of interesting stuff to do with your codebase - for example, use Require.JS for development, simplified module loader for production and, if Require.js configs become messy in your specific project, you can just load a module for your tests purposes directly, passing all of it's dependencies manually. I don't see what exactly Angular's dependency management adds to this.
- camus2 13y agoRequireJS is not a service locator,it's a module loader. It doesnt instanciate anything.AngularJS DI IS a service locator, not a dependency injection container.
- lern_too_spel 13y agoYou're confused. A service locator doesn't have to instantiate anything. Angular's injector, like Guice's injector is a service locator. Because the normal way to use AngularJS is to simply list your dependencies instead of requesting what you want from an injector instance, it is an IOC DI framework.