Reputation: 2696
When writing an application using RequireJS the reuire
d files are stating their dependencies using the define( ['actual dependency name'], function (dependency, variables, ...) {})
which is all nice and dandy for using just one or two, but once you start having deeper dependencies it become a little bit complicated and not very readable or maintainable, i.e.:
define(['modules/module1', 'modules/module2', 'modules/module3', ...],
function (module1, module2, module3, ...) {});
If I add or remove a dependency I have to rewrite my arguments list in the callback function as well, again - not very maintainable...
Is there a better method of doing this? Am I missing something very simple?
Upvotes: 0
Views: 351
Reputation: 13105
Yes, you can be explicit like this:
define(function (require) {
var depA = require('depA'),
depB = require('depB'),
depC = require('depC');
...
});
which should alleviate your maintenance trouble ;)
Upvotes: 3